Add acceptance tests for registered customer subscriptions on checkout

[MAILPOET-3657]
This commit is contained in:
Rostislav Wolny
2021-08-02 17:55:16 +02:00
committed by Veljko V
parent 3849b7fa33
commit c110851a82

View File

@@ -0,0 +1,88 @@
<?php
namespace MailPoet\Test\Acceptance;
use MailPoet\Entities\SubscriberEntity;
use MailPoet\Test\DataFactories\Settings;
use MailPoet\Test\DataFactories\WooCommerceProduct;
/**
* This class contains tests for subscriptions
* of registered customers done via checkout page
*/
class WooCheckoutCustomerSubscriptionsCest {
/** @var Settings */
private $settingsFactory;
/** @var array WooCommerce Product data*/
private $product;
public function _before(\AcceptanceTester $i) {
$i->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();
}
}