Reactivate all inactive subscribers when inactive interval is set to never

[MAILPOET-2003]
This commit is contained in:
Rostislav Wolny
2019-04-24 09:11:56 +02:00
committed by M. Shull
parent e5f5b3534c
commit f5d154d680
4 changed files with 35 additions and 3 deletions

View File

@@ -21,11 +21,12 @@ class InactiveSubscribersTest extends \MailPoetTest {
parent::_before();
}
function testItSchedulesNextRunWhenThereIsNothingToDo() {
function testItReactivateInactiveSubscribersWhenIntervalIsSetToNever() {
$this->settings->set('deactivate_subscriber_after_inactive_days', 0);
$controller_mock = Stub::make(InactiveSubscribersController::class, [
'markInactiveSubscribers' => Stub\Expected::never(),
'markActiveSubscribers' => Stub\Expected::never(),
'reactivateInactiveSubscribers' => Stub\Expected::once(),
], $this);
$worker = new InactiveSubscribers($controller_mock, $this->settings);
@@ -45,6 +46,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
$controller_mock = Stub::make(InactiveSubscribersController::class, [
'markInactiveSubscribers' => Stub\Expected::never(),
'markActiveSubscribers' => Stub\Expected::never(),
'reactivateInactiveSubscribers' => Stub\Expected::never(),
], $this);
$worker = new InactiveSubscribers($controller_mock, $this->settings);
@@ -56,6 +58,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
$controller_mock = Stub::make(InactiveSubscribersController::class, [
'markInactiveSubscribers' => Stub\Expected::once(1),
'markActiveSubscribers' => Stub\Expected::once(1),
'reactivateInactiveSubscribers' => Stub\Expected::never(),
], $this);
$worker = new InactiveSubscribers($controller_mock, $this->settings);
@@ -74,6 +77,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
$controller_mock = Stub::make(InactiveSubscribersController::class, [
'markInactiveSubscribers' => Stub::consecutive(InactiveSubscribers::BATCH_SIZE, InactiveSubscribers::BATCH_SIZE, 1, 'ok'),
'markActiveSubscribers' => Stub::consecutive(InactiveSubscribers::BATCH_SIZE, 1, 'ok'),
'reactivateInactiveSubscribers' => Stub\Expected::never(),
], $this);
$worker = new InactiveSubscribers($controller_mock, $this->settings);
@@ -88,6 +92,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
$controller_mock = Stub::make(InactiveSubscribersController::class, [
'markInactiveSubscribers' => Stub\Expected::once(InactiveSubscribers::BATCH_SIZE),
'markActiveSubscribers' => Stub\Expected::never(),
'reactivateInactiveSubscribers' => Stub\Expected::never(),
], $this);
$worker = new InactiveSubscribers($controller_mock, $this->settings, microtime(true) - (CronHelper::DAEMON_EXECUTION_LIMIT - 1));