diff --git a/lib/Cron/Workers/StatsNotifications/Scheduler.php b/lib/Cron/Workers/StatsNotifications/Scheduler.php index a04c5e441c..ba094f17f4 100644 --- a/lib/Cron/Workers/StatsNotifications/Scheduler.php +++ b/lib/Cron/Workers/StatsNotifications/Scheduler.php @@ -60,6 +60,9 @@ class Scheduler { if(empty(trim($settings['address']))) { return true; } + if(!(bool)Setting::getValue('tracking.enabled')) { + return true; + } return !(bool)$settings['enabled']; } diff --git a/tests/integration/Cron/Workers/StatsNotifications/SchedulerTest.php b/tests/integration/Cron/Workers/StatsNotifications/SchedulerTest.php index 1482584f06..a4fc1af259 100644 --- a/tests/integration/Cron/Workers/StatsNotifications/SchedulerTest.php +++ b/tests/integration/Cron/Workers/StatsNotifications/SchedulerTest.php @@ -18,6 +18,7 @@ class SchedulerTest extends \MailPoetTest { 'enabled' => true, 'address' => 'email@example.com' ]); + Setting::setValue('tracking.enabled', true); } function testShouldSchedule() { @@ -30,6 +31,15 @@ class SchedulerTest extends \MailPoetTest { expect($task)->isInstanceOf(ScheduledTask::class); } + function testShouldNotScheduleIfTrackingIsDisabled() { + Setting::setValue('tracking.enabled', false); + $newsletter_id = 13; + $newsletter = Newsletter::createOrUpdate(['id' => $newsletter_id, 'type' => Newsletter::TYPE_STANDARD]); + $this->stats_notifications->schedule($newsletter); + $notification = StatsNotification::where('newsletter_id', $newsletter_id)->findOne(); + expect($notification)->isEmpty(); + } + function testShouldNotScheduleIfDisabled() { $newsletter_id = 6; Setting::setValue(Worker::SETTINGS_KEY, [