Skip subscribes deactivation when tracking is disabled

[MAILPOET-1791]
This commit is contained in:
Rostislav Wolny
2019-04-18 08:54:49 +02:00
committed by M. Shull
parent b04e235171
commit 8be29b0863
2 changed files with 15 additions and 1 deletions

View File

@ -31,7 +31,8 @@ class InactiveSubscribers extends SimpleWorker {
function processTaskStrategy(ScheduledTask $task) {
$days_to_inactive = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
if ($days_to_inactive === 0) {
$tracking_enabled = (bool)$this->settings->get('tracking.enabled');
if ($days_to_inactive === 0 || !$tracking_enabled) {
self::schedule();
return true;
}

View File

@ -17,6 +17,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
function _before() {
$this->settings = new SettingsController();
\ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
$this->settings->set('tracking.enabled', true);
parent::_before();
}
@ -38,6 +39,18 @@ class InactiveSubscribersTest extends \MailPoetTest {
expect($task->scheduled_at)->greaterThan(new Carbon());
}
function testItDoesNotRunWhenTrackingIsDisabled() {
$this->settings->set('deactivate_subscriber_after_inactive_days', 10);
$this->settings->set('tracking.enabled', false);
$controller_mock = Stub::make(InactiveSubscribersController::class, [
'markInactiveSubscribers' => Stub\Expected::never(),
'markActiveSubscribers' => Stub\Expected::never(),
], $this);
$worker = new InactiveSubscribers($controller_mock, $this->settings);
$worker->processTaskStrategy(ScheduledTask::createOrUpdate([]));
}
function testItSchedulesNextRunWhenFinished() {
$this->settings->set('deactivate_subscriber_after_inactive_days', 5);
$controller_mock = Stub::make(InactiveSubscribersController::class, [