After updating to Codeception v4 inject doesn't work since services in DI needs WP to be loaded. Injecting data factories is also not recommended practice since they are not designed to work as singleton and may that test influence each other and cause some flakiness. [MAILPOET-2973]
58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace MailPoet\Test\Acceptance;
|
|
|
|
use MailPoet\Test\DataFactories\Segment;
|
|
use MailPoet\Test\DataFactories\Settings;
|
|
use MailPoet\Test\DataFactories\Subscriber;
|
|
use PHPUnit\Framework\Exception;
|
|
|
|
class SettingsInactiveSubscribersChangeCest {
|
|
|
|
const INACTIVE_SUBSCRIBERS_COUNT = 2;
|
|
const INACTIVE_LIST_NAME = 'Lazy Subscribers';
|
|
|
|
/** @var Settings */
|
|
private $settings;
|
|
|
|
public function _before() {
|
|
$this->settings = new Settings();
|
|
$segment = (new Segment())->withName(self::INACTIVE_LIST_NAME)->create();
|
|
(new Subscriber())->withSegments([$segment])->create();
|
|
for ($i = 0; $i < self::INACTIVE_SUBSCRIBERS_COUNT; $i++) {
|
|
(new Subscriber())->withStatus('inactive')->withSegments([$segment])->create();
|
|
}
|
|
$this->settings
|
|
->withDeactivateSubscriberAfter6Months()
|
|
->withTrackingEnabled()
|
|
->withCronTriggerMethod('WordPress');
|
|
}
|
|
|
|
public function inactiveSubscribersSettingsChange(\AcceptanceTester $i) {
|
|
$i->wantTo('Change inactive users settings and reactivate all subscribers');
|
|
$i->login();
|
|
$i->amOnMailPoetPage('Settings');
|
|
$i->click('[data-automation-id="settings-advanced-tab"]');
|
|
$i->waitForElement('[data-automation-id="inactive-subscribers-option-never"]');
|
|
$i->click('[data-automation-id="inactive-subscribers-option-never"]');
|
|
$i->click('[data-automation-id="settings-submit-button"]');
|
|
$i->waitForText('Settings saved');
|
|
$i->amOnMailPoetPage('Subscribers');
|
|
// Subscribers are activated in background so we do a couple of reloads
|
|
for ($index = 0; $index < 15; $index++) {
|
|
try {
|
|
$i->wait(2);
|
|
$i->reloadPage();
|
|
$i->waitForListingItemsToLoad();
|
|
$i->see('Inactive');
|
|
$i->dontSeeElement('[data-automation-id="filters_inactive"] .mailpoet-listing-groups-count');
|
|
return;
|
|
} catch (Exception $e) {
|
|
continue;
|
|
}
|
|
}
|
|
$i->see('Inactive');
|
|
$i->dontSeeElement('[data-automation-id="filters_inactive"] .mailpoet-listing-groups-count');
|
|
}
|
|
}
|