• Resolved elenktik

    (@elenktik)


    I am using Woocommere with the Subscription extension. I have a tons of plugins, selfwritten as-well as external that change behavior of subscription renewals (adding special meta keys, special discount, etc.).

    I want to write feature tests like this:

    
     public function test_subscription() 
     {
        $subscription = $this->create_subscription([..]);
        $subscription->renewal([..]);
        $this->assertTrue('15%', $subscription->getMetaKey('discount'));
      }
    

    So I would like to trigger subscriptions and order processing and see if my WP together with all plugins has the expected output.

    My question is, is there a library that I can use for that?

    I found https://developer.woocommerce.com/testing-extensions-and-maintaining-quality-code/setting-up-a-local-environment-for-testing/ and I believe my test is considered an “End-to-end” test? I believe “WooCommerce Core E2E Tests ” comes closest, as it seems to support cases like changing order status. But how can I create tests for subscriptions?

    I also checked out https://woocommerce.com/document/testing-subscription-renewal-payments/ but this does not mention automated tests.

    I also found this test suite https://github.com/Automattic/woocommerce-subscriptions-core but from the docs alone I don’t really understand how to integrate those test with my own wordpress application. It seems to just write test for plain WP with subscription plugin?

    Would be happy about any advice.

Viewing 1 replies (of 1 total)
  • Igor H

    (@ihereira)

    Hello,

    To clarify, is the goal to offer a discount when a subscription is renewing? You can use coupons (recurring coupons), you can find more information right here.

    If that is not the goal, please provide us with more details, thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘How to make a subscription test?’ is closed to new replies.