diff --git a/tests/acceptance/Subscriptions/WooCheckoutCustomerSubscriptionsCest.php b/tests/acceptance/Subscriptions/WooCheckoutCustomerSubscriptionsCest.php new file mode 100644 index 0000000000..25d1ce6571 --- /dev/null +++ b/tests/acceptance/Subscriptions/WooCheckoutCustomerSubscriptionsCest.php @@ -0,0 +1,88 @@ +activateWooCommerce(); + $this->product = (new WooCommerceProduct($i))->create(); + $this->settingsFactory = new Settings(); + $this->settingsFactory->withWooCommerceListImportPageDisplayed(true); + $this->settingsFactory->withCookieRevenueTrackingDisabled(); + } + + public function checkoutOptInDisabled(\AcceptanceTester $i) { + $this->settingsFactory->withWooCommerceCheckoutOptinDisabled(); + $this->settingsFactory->withConfirmationEmailEnabled(); + $customerEmail = 'woo_customer_noptin@example.com'; + $i->orderProductWithRegistration($this->product, $customerEmail, false); + $i->login(); + $i->checkSubscriberStatusAndLists($customerEmail, SubscriberEntity::STATUS_UNCONFIRMED, ['WordPress Users'], ['WooCommerce Customers']); + $i->seeConfirmationEmailWasNotReceived(); + } + + public function checkoutOptInChecked(\AcceptanceTester $i) { + $this->settingsFactory->withWooCommerceCheckoutOptinEnabled(); + $this->settingsFactory->withConfirmationEmailEnabled(); + $customerEmail = 'woo_customer_check@example.com'; + $i->orderProductWithRegistration($this->product, $customerEmail, true); + $i->login(); + $i->checkSubscriberStatusAndLists($customerEmail, SubscriberEntity::STATUS_UNCONFIRMED, ['WooCommerce Customers', 'WordPress Users']); + $i->seeConfirmationEmailWasReceived(); + } + + public function checkoutOptInUnchecked(\AcceptanceTester $i) { + $this->settingsFactory->withWooCommerceCheckoutOptinEnabled(); + $this->settingsFactory->withConfirmationEmailEnabled(); + $customerEmail = 'woo_customer_uncheck@example.com'; + $i->orderProductWithRegistration($this->product, $customerEmail, false); + $i->login(); + $i->checkSubscriberStatusAndLists($customerEmail, SubscriberEntity::STATUS_UNSUBSCRIBED, ['WordPress Users'], ['WooCommerce Customers']); + $i->seeConfirmationEmailWasNotReceived(); + } + + public function checkoutOptInDisabledNoConfirmation(\AcceptanceTester $i) { + $this->settingsFactory->withWooCommerceCheckoutOptinDisabled(); + $this->settingsFactory->withConfirmationEmailDisabled(); + $customerEmail = 'woo_customer_noptin@example.com'; + $i->orderProductWithRegistration($this->product, $customerEmail, false); + $i->login(); + $i->checkSubscriberStatusAndLists($customerEmail, SubscriberEntity::STATUS_SUBSCRIBED, ['WordPress Users'], ['WooCommerce Customers']); + $i->seeConfirmationEmailWasNotReceived(); + } + + public function checkoutOptInCheckedNoConfirmation(\AcceptanceTester $i) { + $this->settingsFactory->withWooCommerceCheckoutOptinEnabled(); + $this->settingsFactory->withConfirmationEmailDisabled(); + $customerEmail = 'woo_customer_check@example.com'; + $i->orderProductWithRegistration($this->product, $customerEmail, true); + $i->login(); + $i->checkSubscriberStatusAndLists($customerEmail, SubscriberEntity::STATUS_SUBSCRIBED, ['WooCommerce Customers', 'WordPress Users']); + $i->seeConfirmationEmailWasNotReceived(); + } + + public function checkoutOptInUncheckedNoConfirmation(\AcceptanceTester $i) { + $this->settingsFactory->withWooCommerceCheckoutOptinEnabled(); + $this->settingsFactory->withConfirmationEmailDisabled(); + $customerEmail = 'woo_customer_uncheck@example.com'; + $i->orderProductWithRegistration($this->product, $customerEmail, false); + $i->login(); + $i->checkSubscriberStatusAndLists($customerEmail, SubscriberEntity::STATUS_UNSUBSCRIBED, ['WordPress Users'], ['WooCommerce Customers']); + $i->seeConfirmationEmailWasNotReceived(); + } +}