Fix flakey scheduler test
[MAILPOET-2896]
This commit is contained in:
@@ -36,7 +36,7 @@ class ScheduledTask extends Model {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->wp = new WPFunctions();
|
||||
$this->wp = WPFunctions::get();
|
||||
}
|
||||
|
||||
public function subscribers() {
|
||||
|
@@ -50,7 +50,13 @@ class AbandonedCartTest extends \MailPoetTest {
|
||||
Carbon::setTestNow($this->currentTime);
|
||||
|
||||
$this->wp = $this->makeEmpty(WPFunctions::class, [
|
||||
'currentTime' => $this->currentTime->getTimestamp(),
|
||||
'currentTime' => function ($arg) {
|
||||
if ($arg === 'timestamp') {
|
||||
return $this->currentTime->getTimestamp();
|
||||
} elseif ($arg === 'mysql') {
|
||||
return $this->currentTime->format('Y-m-d H:i:s');
|
||||
}
|
||||
},
|
||||
]);
|
||||
WPFunctions::set($this->wp);
|
||||
|
||||
|
@@ -317,8 +317,14 @@ class SchedulerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItReschedulesQueueDeliveryWhenMailpoetSubscriberHasNotConfirmedSubscription() {
|
||||
$currentTime = Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'));
|
||||
$timestamp = WPFunctions::get()->currentTime('timestamp');
|
||||
$wpFunctions = $this->make(WPFunctions::class, [
|
||||
'currentTime' => $timestamp,
|
||||
]);
|
||||
WPFunctions::set($wpFunctions);
|
||||
$currentTime = Carbon::createFromTimestamp($timestamp);
|
||||
Carbon::setTestNow($currentTime); // mock carbon to return current time
|
||||
|
||||
$subscriber = $this->_createSubscriber($wpUserId = null, 'unconfirmed');
|
||||
$segment = $this->_createSegment();
|
||||
$subscriberSegment = $this->_createSubscriberSegment($subscriber->id, $segment->id);
|
||||
@@ -344,6 +350,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(Carbon::parse($updatedQueue->scheduledAt))->equals(
|
||||
$currentTime->addMinutes(ScheduledTask::BASIC_RESCHEDULE_TIMEOUT)
|
||||
);
|
||||
WPFunctions::set(new WPFunctions());
|
||||
}
|
||||
|
||||
public function testItDoesntRunQueueDeliveryWhenMailpoetSubscriberHasUnsubscribed() {
|
||||
|
Reference in New Issue
Block a user