Fix PEAR.WhiteSpace.ScopeClosingBrace rule in tests [MAILPOET-989]
This commit is contained in:
@@ -76,11 +76,11 @@
|
|||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Closing brace should be at the same level as opening brace -->
|
<!-- Closing brace should be at the same level as opening brace -->
|
||||||
<!-- <rule ref="PEAR.WhiteSpace.ScopeClosingBrace">
|
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="indent" value="2"/>
|
<property name="indent" value="2"/>
|
||||||
</properties>
|
</properties>
|
||||||
</rule> -->
|
</rule>
|
||||||
|
|
||||||
<!-- Each class must be in a file by itself and must be under a namespace -->
|
<!-- Each class must be in a file by itself and must be under a namespace -->
|
||||||
<!-- <rule ref="PSR1.Classes.ClassDeclaration"/> -->
|
<!-- <rule ref="PSR1.Classes.ClassDeclaration"/> -->
|
||||||
|
@@ -81,7 +81,9 @@ class ServicesTest extends MailPoetTest {
|
|||||||
$this->services_endpoint->bridge = Stub::make(
|
$this->services_endpoint->bridge = Stub::make(
|
||||||
new Bridge(),
|
new Bridge(),
|
||||||
array(
|
array(
|
||||||
'checkMSSKey' => function() { throw new \Exception('test'); },
|
'checkMSSKey' => function() {
|
||||||
|
throw new \Exception('test');
|
||||||
|
},
|
||||||
'storeMSSKeyAndState' => Stub::never()
|
'storeMSSKeyAndState' => Stub::never()
|
||||||
),
|
),
|
||||||
$this
|
$this
|
||||||
@@ -176,7 +178,9 @@ class ServicesTest extends MailPoetTest {
|
|||||||
$this->services_endpoint->bridge = Stub::make(
|
$this->services_endpoint->bridge = Stub::make(
|
||||||
new Bridge(),
|
new Bridge(),
|
||||||
array(
|
array(
|
||||||
'checkPremiumKey' => function() { throw new \Exception('test'); },
|
'checkPremiumKey' => function() {
|
||||||
|
throw new \Exception('test');
|
||||||
|
},
|
||||||
'storePremiumKeyAndState' => Stub::never()
|
'storePremiumKeyAndState' => Stub::never()
|
||||||
),
|
),
|
||||||
$this
|
$this
|
||||||
|
@@ -10,7 +10,9 @@ class RendererTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItUsesCorrectAssetsManifestFilenames() {
|
function testItUsesCorrectAssetsManifestFilenames() {
|
||||||
$renderer = Stub::make(new Renderer(),
|
$renderer = Stub::make(new Renderer(),
|
||||||
array('getAssetManifest' => function($manifest) { return $manifest; })
|
array('getAssetManifest' => function($manifest) {
|
||||||
|
return $manifest;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
$renderer->__construct();
|
$renderer->__construct();
|
||||||
expect($renderer->assets_manifest_js)->equals(Env::$assets_path . '/js/manifest.json');
|
expect($renderer->assets_manifest_js)->equals(Env::$assets_path . '/js/manifest.json');
|
||||||
@@ -71,7 +73,9 @@ class RendererTest extends MailPoetTest {
|
|||||||
array(
|
array(
|
||||||
'renderer' => Stub::makeEmpty('Twig_Environment',
|
'renderer' => Stub::makeEmpty('Twig_Environment',
|
||||||
array(
|
array(
|
||||||
'render' => Stub::atLeastOnce(function() { return 'test render'; }),
|
'render' => Stub::atLeastOnce(function() {
|
||||||
|
return 'test render';
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
$this
|
$this
|
||||||
),
|
),
|
||||||
@@ -115,4 +119,4 @@ class RendererTest extends MailPoetTest {
|
|||||||
if(is_readable(Env::$temp_path . '/js.json')) unlink(Env::$temp_path . '/js.json');
|
if(is_readable(Env::$temp_path . '/js.json')) unlink(Env::$temp_path . '/js.json');
|
||||||
if(is_readable(Env::$temp_path . '/css.json')) unlink(Env::$temp_path . '/css.json');
|
if(is_readable(Env::$temp_path . '/css.json')) unlink(Env::$temp_path . '/css.json');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,10 +69,10 @@ class DaemonTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItCanExecuteWorkers() {
|
function testItCanExecuteWorkers() {
|
||||||
$daemon = Stub::make(new Daemon(true), array(
|
$daemon = Stub::make(new Daemon(true), array(
|
||||||
'executeScheduleWorker' => Stub::exactly(1, function() { }),
|
'executeScheduleWorker' => Stub::exactly(1),
|
||||||
'executeQueueWorker' => Stub::exactly(1, function() { }),
|
'executeQueueWorker' => Stub::exactly(1),
|
||||||
'pauseExecution' => function($a) { },
|
'pauseExecution' => null,
|
||||||
'callSelf' => function() { }
|
'callSelf' => null
|
||||||
), $this);
|
), $this);
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => 123
|
'token' => 123
|
||||||
@@ -90,8 +90,8 @@ class DaemonTest extends MailPoetTest {
|
|||||||
'executeQueueWorker' => function() {
|
'executeQueueWorker' => function() {
|
||||||
throw new \Exception();
|
throw new \Exception();
|
||||||
},
|
},
|
||||||
'pauseExecution' => function($a) { },
|
'pauseExecution' => null,
|
||||||
'callSelf' => function() { }
|
'callSelf' => null
|
||||||
), $this);
|
), $this);
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => 123
|
'token' => 123
|
||||||
@@ -103,13 +103,13 @@ class DaemonTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItCanPauseExecution() {
|
function testItCanPauseExecution() {
|
||||||
$daemon = Stub::make(new Daemon(true), array(
|
$daemon = Stub::make(new Daemon(true), array(
|
||||||
'executeScheduleWorker' => function() { },
|
'executeScheduleWorker' => null,
|
||||||
'executeQueueWorker' => function() { },
|
'executeQueueWorker' => null,
|
||||||
'pauseExecution' => Stub::exactly(1, function($pause_delay) {
|
'pauseExecution' => Stub::exactly(1, function($pause_delay) {
|
||||||
expect($pause_delay)->lessThan(CronHelper::DAEMON_EXECUTION_LIMIT);
|
expect($pause_delay)->lessThan(CronHelper::DAEMON_EXECUTION_LIMIT);
|
||||||
expect($pause_delay)->greaterThan(CronHelper::DAEMON_EXECUTION_LIMIT - 1);
|
expect($pause_delay)->greaterThan(CronHelper::DAEMON_EXECUTION_LIMIT - 1);
|
||||||
}),
|
}),
|
||||||
'callSelf' => function() { }
|
'callSelf' => null
|
||||||
), $this);
|
), $this);
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => 123
|
'token' => 123
|
||||||
@@ -125,9 +125,9 @@ class DaemonTest extends MailPoetTest {
|
|||||||
'executeScheduleWorker' => function() {
|
'executeScheduleWorker' => function() {
|
||||||
Setting::deleteValue(CronHelper::DAEMON_SETTING);
|
Setting::deleteValue(CronHelper::DAEMON_SETTING);
|
||||||
},
|
},
|
||||||
'executeQueueWorker' => function() { },
|
'executeQueueWorker' => null,
|
||||||
'pauseExecution' => function() { },
|
'pauseExecution' => null,
|
||||||
'terminateRequest' => Stub::exactly(1, function() { })
|
'terminateRequest' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => 123
|
'token' => 123
|
||||||
@@ -145,9 +145,9 @@ class DaemonTest extends MailPoetTest {
|
|||||||
array('token' => 567)
|
array('token' => 567)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'executeQueueWorker' => function() { },
|
'executeQueueWorker' => null,
|
||||||
'pauseExecution' => function() { },
|
'pauseExecution' => null,
|
||||||
'terminateRequest' => Stub::exactly(1, function() { })
|
'terminateRequest' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => 123
|
'token' => 123
|
||||||
@@ -159,10 +159,10 @@ class DaemonTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItUpdatesDaemonTokenDuringExecution() {
|
function testItUpdatesDaemonTokenDuringExecution() {
|
||||||
$daemon = Stub::make(new Daemon(true), array(
|
$daemon = Stub::make(new Daemon(true), array(
|
||||||
'executeScheduleWorker' => function() { },
|
'executeScheduleWorker' => null,
|
||||||
'executeQueueWorker' => function() { },
|
'executeQueueWorker' => null,
|
||||||
'pauseExecution' => function() { },
|
'pauseExecution' => null,
|
||||||
'callSelf' => function() { }
|
'callSelf' => null
|
||||||
), $this);
|
), $this);
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => 123
|
'token' => 123
|
||||||
@@ -178,12 +178,12 @@ class DaemonTest extends MailPoetTest {
|
|||||||
ignore_user_abort(0);
|
ignore_user_abort(0);
|
||||||
expect(ignore_user_abort())->equals(0);
|
expect(ignore_user_abort())->equals(0);
|
||||||
$daemon = Stub::make(new Daemon(true), array(
|
$daemon = Stub::make(new Daemon(true), array(
|
||||||
'pauseExecution' => function() { },
|
'pauseExecution' => null,
|
||||||
// workers should be executed
|
// workers should be executed
|
||||||
'executeScheduleWorker' => Stub::exactly(1, function() { }),
|
'executeScheduleWorker' => Stub::exactly(1),
|
||||||
'executeQueueWorker' => Stub::exactly(1, function() { }),
|
'executeQueueWorker' => Stub::exactly(1),
|
||||||
// daemon should call itself
|
// daemon should call itself
|
||||||
'callSelf' => Stub::exactly(1, function() { }),
|
'callSelf' => Stub::exactly(1),
|
||||||
), $this);
|
), $this);
|
||||||
$data = array(
|
$data = array(
|
||||||
'token' => 123
|
'token' => 123
|
||||||
|
@@ -29,7 +29,9 @@ class KeyCheckWorkerTest extends MailPoetTest {
|
|||||||
$worker = Stub::make(
|
$worker = Stub::make(
|
||||||
$this->worker,
|
$this->worker,
|
||||||
array(
|
array(
|
||||||
'checkKey' => function () { throw new \Exception; },
|
'checkKey' => function () {
|
||||||
|
throw new \Exception;
|
||||||
|
},
|
||||||
'reschedule' => Stub::once()
|
'reschedule' => Stub::once()
|
||||||
),
|
),
|
||||||
$this
|
$this
|
||||||
|
@@ -213,7 +213,9 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
|
|
||||||
// return false when WP user cannot be verified
|
// return false when WP user cannot be verified
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'verifyWPSubscriber' => Stub::exactly(1, function() { return false; })
|
'verifyWPSubscriber' => Stub::exactly(1, function() {
|
||||||
|
return false;
|
||||||
|
})
|
||||||
), $this);
|
), $this);
|
||||||
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->false();
|
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->false();
|
||||||
}
|
}
|
||||||
@@ -226,7 +228,9 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
|
|
||||||
// return false when subscriber cannot be verified
|
// return false when subscriber cannot be verified
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'verifyMailpoetSubscriber' => Stub::exactly(1, function() { return false; })
|
'verifyMailpoetSubscriber' => Stub::exactly(1, function() {
|
||||||
|
return false;
|
||||||
|
})
|
||||||
), $this);
|
), $this);
|
||||||
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->false();
|
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->false();
|
||||||
}
|
}
|
||||||
@@ -239,7 +243,7 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
$queue = $this->_createQueue($newsletter->id);
|
$queue = $this->_createQueue($newsletter->id);
|
||||||
$queue->subscribers = serialize(array('to_process' => array(1)));
|
$queue->subscribers = serialize(array('to_process' => array(1)));
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'verifyMailpoetSubscriber' => Stub::exactly(1, function() { })
|
'verifyMailpoetSubscriber' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
expect($queue->status)->notNull();
|
expect($queue->status)->notNull();
|
||||||
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->true();
|
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->true();
|
||||||
@@ -255,7 +259,7 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
$queue = $this->_createQueue($newsletter->id);
|
$queue = $this->_createQueue($newsletter->id);
|
||||||
$queue->subscribers = serialize(array('to_process' => array(1)));
|
$queue->subscribers = serialize(array('to_process' => array(1)));
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'verifyWPSubscriber' => Stub::exactly(1, function() { })
|
'verifyWPSubscriber' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
expect($queue->status)->notNull();
|
expect($queue->status)->notNull();
|
||||||
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->true();
|
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->true();
|
||||||
@@ -378,7 +382,9 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
|
|
||||||
// delete or reschedule queue when segments don't exist
|
// delete or reschedule queue when segments don't exist
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'deleteQueueOrUpdateNextRunDate' => Stub::exactly(1, function() { return false; })
|
'deleteQueueOrUpdateNextRunDate' => Stub::exactly(1, function() {
|
||||||
|
return false;
|
||||||
|
})
|
||||||
), $this);
|
), $this);
|
||||||
expect($scheduler->processPostNotificationNewsletter($newsletter, $queue))->false();
|
expect($scheduler->processPostNotificationNewsletter($newsletter, $queue))->false();
|
||||||
}
|
}
|
||||||
@@ -391,7 +397,9 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
|
|
||||||
// delete or reschedule queue when there are no subscribers in segments
|
// delete or reschedule queue when there are no subscribers in segments
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'deleteQueueOrUpdateNextRunDate' => Stub::exactly(1, function() { return false; })
|
'deleteQueueOrUpdateNextRunDate' => Stub::exactly(1, function() {
|
||||||
|
return false;
|
||||||
|
})
|
||||||
), $this);
|
), $this);
|
||||||
expect($scheduler->processPostNotificationNewsletter($newsletter, $queue))->false();
|
expect($scheduler->processPostNotificationNewsletter($newsletter, $queue))->false();
|
||||||
}
|
}
|
||||||
@@ -463,7 +471,7 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||||
$queue->save();
|
$queue->save();
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'processWelcomeNewsletter' => Stub::exactly(1, function($newsletter, $queue) { })
|
'processWelcomeNewsletter' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$scheduler->timer = microtime(true);
|
$scheduler->timer = microtime(true);
|
||||||
$scheduler->process();
|
$scheduler->process();
|
||||||
@@ -475,7 +483,7 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||||
$queue->save();
|
$queue->save();
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'processPostNotificationNewsletter' => Stub::exactly(1, function($newsletter, $queue) { })
|
'processPostNotificationNewsletter' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$scheduler->timer = microtime(true);
|
$scheduler->timer = microtime(true);
|
||||||
$scheduler->process();
|
$scheduler->process();
|
||||||
@@ -487,7 +495,7 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||||
$queue->save();
|
$queue->save();
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'processScheduledStandardNewsletter' => Stub::exactly(1, function($newsletter, $queue) { })
|
'processScheduledStandardNewsletter' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$scheduler->timer = microtime(true);
|
$scheduler->timer = microtime(true);
|
||||||
$scheduler->process();
|
$scheduler->process();
|
||||||
@@ -499,7 +507,7 @@ class SchedulerTest extends MailPoetTest {
|
|||||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||||
$queue->save();
|
$queue->save();
|
||||||
$scheduler = Stub::make(new Scheduler(), array(
|
$scheduler = Stub::make(new Scheduler(), array(
|
||||||
'processPostNotificationNewsletter' => Stub::exactly(1, function($newsletter, $queue) { })
|
'processPostNotificationNewsletter' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$scheduler->timer = microtime(true) - CronHelper::DAEMON_EXECUTION_LIMIT;
|
$scheduler->timer = microtime(true) - CronHelper::DAEMON_EXECUTION_LIMIT;
|
||||||
try {
|
try {
|
||||||
|
@@ -122,14 +122,14 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
$sending_queue_worker = Stub::make(
|
$sending_queue_worker = Stub::make(
|
||||||
new SendingQueueWorker(),
|
new SendingQueueWorker(),
|
||||||
array(
|
array(
|
||||||
'enforceSendingAndExecutionLimits' => Stub::exactly(1, function() { })
|
'enforceSendingAndExecutionLimits' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$sending_queue_worker->__construct(
|
$sending_queue_worker->__construct(
|
||||||
$timer = false,
|
$timer = false,
|
||||||
Stub::make(
|
Stub::make(
|
||||||
new MailerTask(),
|
new MailerTask(),
|
||||||
array(
|
array(
|
||||||
'send' => function() { }
|
'send' => null
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -162,7 +162,7 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
Stub::make(
|
Stub::make(
|
||||||
new MailerTask(),
|
new MailerTask(),
|
||||||
array(
|
array(
|
||||||
'send' => function() { }
|
'send' => null
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -187,7 +187,7 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
// this function returns a queue object
|
// this function returns a queue object
|
||||||
return (object)array('status' => null);
|
return (object)array('status' => null);
|
||||||
},
|
},
|
||||||
'enforceSendingAndExecutionLimits' => Stub::exactly(2, function() { })
|
'enforceSendingAndExecutionLimits' => Stub::exactly(2)
|
||||||
), $this);
|
), $this);
|
||||||
$sending_queue_worker->__construct();
|
$sending_queue_worker->__construct();
|
||||||
$sending_queue_worker->process();
|
$sending_queue_worker->process();
|
||||||
@@ -306,7 +306,9 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
expect(!empty($newsletter[0]['body']['text']))->true();
|
expect(!empty($newsletter[0]['body']['text']))->true();
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
'getProcessingMethod' => Stub::exactly(1, function() { return 'bulk'; })
|
'getProcessingMethod' => Stub::exactly(1, function() {
|
||||||
|
return 'bulk';
|
||||||
|
})
|
||||||
),
|
),
|
||||||
$this
|
$this
|
||||||
)
|
)
|
||||||
@@ -406,7 +408,9 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
$sending_queue_worker = $this->sending_queue_worker;
|
$sending_queue_worker = $this->sending_queue_worker;
|
||||||
$sending_queue_worker->mailer_task = Stub::make(
|
$sending_queue_worker->mailer_task = Stub::make(
|
||||||
new MailerTask(),
|
new MailerTask(),
|
||||||
array('send' => Stub::exactly(1, function($newsletter, $subscriber) { return true; })),
|
array('send' => Stub::exactly(1, function() {
|
||||||
|
return true;
|
||||||
|
})),
|
||||||
$this
|
$this
|
||||||
);
|
);
|
||||||
$sending_queue_worker->process();
|
$sending_queue_worker->process();
|
||||||
@@ -445,7 +449,7 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
$sending_queue_worker = $this->sending_queue_worker;
|
$sending_queue_worker = $this->sending_queue_worker;
|
||||||
$sending_queue_worker->mailer_task = Stub::make(
|
$sending_queue_worker->mailer_task = Stub::make(
|
||||||
new MailerTask(),
|
new MailerTask(),
|
||||||
array('send' => function($newsletter, $subscriber) { return true; })
|
array('send' => true)
|
||||||
);
|
);
|
||||||
$sending_queue_worker->process();
|
$sending_queue_worker->process();
|
||||||
|
|
||||||
@@ -467,7 +471,7 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
$sending_queue_worker = $this->sending_queue_worker;
|
$sending_queue_worker = $this->sending_queue_worker;
|
||||||
$sending_queue_worker->mailer_task = Stub::make(
|
$sending_queue_worker->mailer_task = Stub::make(
|
||||||
new MailerTask(),
|
new MailerTask(),
|
||||||
array('send' => function($newsletter, $subscriber) { return true; })
|
array('send' => true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// newsletter is sent to existing subscriber
|
// newsletter is sent to existing subscriber
|
||||||
@@ -490,7 +494,7 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
$sending_queue_worker = $this->sending_queue_worker;
|
$sending_queue_worker = $this->sending_queue_worker;
|
||||||
$sending_queue_worker->mailer_task = Stub::make(
|
$sending_queue_worker->mailer_task = Stub::make(
|
||||||
new MailerTask(),
|
new MailerTask(),
|
||||||
array('send' => function($newsletter, $subscriber) { return true; })
|
array('send' => true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// newsletter is not sent to globally unsubscribed subscriber
|
// newsletter is not sent to globally unsubscribed subscriber
|
||||||
@@ -508,7 +512,7 @@ class SendingQueueTest extends MailPoetTest {
|
|||||||
$sending_queue_worker = $this->sending_queue_worker;
|
$sending_queue_worker = $this->sending_queue_worker;
|
||||||
$sending_queue_worker->mailer_task = Stub::make(
|
$sending_queue_worker->mailer_task = Stub::make(
|
||||||
new MailerTask(),
|
new MailerTask(),
|
||||||
array('send' => function($newsletter, $subscriber) { return true; })
|
array('send' => true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// newsletter is not sent to subscriber unsubscribed from segment
|
// newsletter is not sent to subscriber unsubscribed from segment
|
||||||
|
@@ -107,7 +107,9 @@ class MailerTaskTest extends MailPoetTest {
|
|||||||
(object)array(
|
(object)array(
|
||||||
'mailer_instance' => Stub::make(
|
'mailer_instance' => Stub::make(
|
||||||
$php_mail_class,
|
$php_mail_class,
|
||||||
array('send' => Stub::exactly(1, function($newsletter, $subscriber) { return true; })),
|
array('send' => Stub::exactly(1, function() {
|
||||||
|
return true;
|
||||||
|
})),
|
||||||
$this
|
$this
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@@ -37,7 +37,7 @@ class ViewInBrowserRouterTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItAbortsWhenBrowserPreviewDataIsMissing() {
|
function testItAbortsWhenBrowserPreviewDataIsMissing() {
|
||||||
$view_in_browser = Stub::make($this->view_in_browser, array(
|
$view_in_browser = Stub::make($this->view_in_browser, array(
|
||||||
'_abort' => Stub::exactly(2, function() { })
|
'_abort' => Stub::exactly(2)
|
||||||
), $this);
|
), $this);
|
||||||
// newsletter ID is required
|
// newsletter ID is required
|
||||||
$data = $this->browser_preview_data;
|
$data = $this->browser_preview_data;
|
||||||
@@ -51,7 +51,7 @@ class ViewInBrowserRouterTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItAbortsWhenBrowserPreviewDataIsInvalid() {
|
function testItAbortsWhenBrowserPreviewDataIsInvalid() {
|
||||||
$view_in_browser = Stub::make($this->view_in_browser, array(
|
$view_in_browser = Stub::make($this->view_in_browser, array(
|
||||||
'_abort' => Stub::exactly(3, function() { })
|
'_abort' => Stub::exactly(3)
|
||||||
), $this);
|
), $this);
|
||||||
// newsletter ID is invalid
|
// newsletter ID is invalid
|
||||||
$data = $this->browser_preview_data;
|
$data = $this->browser_preview_data;
|
||||||
@@ -186,7 +186,7 @@ class ViewInBrowserRouterTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItReturnsViewActionResult() {
|
function testItReturnsViewActionResult() {
|
||||||
$view_in_browser = Stub::make($this->view_in_browser, array(
|
$view_in_browser = Stub::make($this->view_in_browser, array(
|
||||||
'_displayNewsletter' => Stub::exactly(1, function() { })
|
'_displayNewsletter' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$view_in_browser->data = $view_in_browser->_processBrowserPreviewData($this->browser_preview_data);
|
$view_in_browser->data = $view_in_browser->_processBrowserPreviewData($this->browser_preview_data);
|
||||||
$view_in_browser->view();
|
$view_in_browser->view();
|
||||||
|
@@ -49,7 +49,7 @@ class ClicksTest extends MailPoetTest {
|
|||||||
function testItAbortsWhenTrackDataIsEmptyOrMissingLink() {
|
function testItAbortsWhenTrackDataIsEmptyOrMissingLink() {
|
||||||
// abort function should be called twice:
|
// abort function should be called twice:
|
||||||
$clicks = Stub::make($this->clicks, array(
|
$clicks = Stub::make($this->clicks, array(
|
||||||
'abort' => Stub::exactly(2, function() { })
|
'abort' => Stub::exactly(2)
|
||||||
), $this);
|
), $this);
|
||||||
$data = $this->track_data;
|
$data = $this->track_data;
|
||||||
// 1. when tracking data does not exist
|
// 1. when tracking data does not exist
|
||||||
@@ -64,7 +64,7 @@ class ClicksTest extends MailPoetTest {
|
|||||||
$data->subscriber->wp_user_id = 99;
|
$data->subscriber->wp_user_id = 99;
|
||||||
$data->preview = true;
|
$data->preview = true;
|
||||||
$clicks = Stub::make($this->clicks, array(
|
$clicks = Stub::make($this->clicks, array(
|
||||||
'redirectToUrl' => function() { }
|
'redirectToUrl' => null
|
||||||
), $this);
|
), $this);
|
||||||
$clicks->track($data);
|
$clicks->track($data);
|
||||||
expect(StatisticsClicks::findMany())->isEmpty();
|
expect(StatisticsClicks::findMany())->isEmpty();
|
||||||
@@ -74,7 +74,7 @@ class ClicksTest extends MailPoetTest {
|
|||||||
function testItTracksClickAndOpenEvent() {
|
function testItTracksClickAndOpenEvent() {
|
||||||
$data = $this->track_data;
|
$data = $this->track_data;
|
||||||
$clicks = Stub::make($this->clicks, array(
|
$clicks = Stub::make($this->clicks, array(
|
||||||
'redirectToUrl' => function() { }
|
'redirectToUrl' => null
|
||||||
), $this);
|
), $this);
|
||||||
$clicks->track($data);
|
$clicks->track($data);
|
||||||
expect(StatisticsClicks::findMany())->notEmpty();
|
expect(StatisticsClicks::findMany())->notEmpty();
|
||||||
@@ -83,14 +83,14 @@ class ClicksTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItRedirectsToUrlAfterTracking() {
|
function testItRedirectsToUrlAfterTracking() {
|
||||||
$clicks = Stub::make($this->clicks, array(
|
$clicks = Stub::make($this->clicks, array(
|
||||||
'redirectToUrl' => Stub::exactly(1, function() { })
|
'redirectToUrl' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$clicks->track($this->track_data);
|
$clicks->track($this->track_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItIncrementsClickEventCount() {
|
function testItIncrementsClickEventCount() {
|
||||||
$clicks = Stub::make($this->clicks, array(
|
$clicks = Stub::make($this->clicks, array(
|
||||||
'redirectToUrl' => function() { }
|
'redirectToUrl' => null
|
||||||
), $this);
|
), $this);
|
||||||
$clicks->track($this->track_data);
|
$clicks->track($this->track_data);
|
||||||
expect(StatisticsClicks::findMany()[0]->count)->equals(1);
|
expect(StatisticsClicks::findMany()[0]->count)->equals(1);
|
||||||
@@ -111,7 +111,7 @@ class ClicksTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItFailsToConvertsInvalidShortcodeToUrl() {
|
function testItFailsToConvertsInvalidShortcodeToUrl() {
|
||||||
$clicks = Stub::make($this->clicks, array(
|
$clicks = Stub::make($this->clicks, array(
|
||||||
'abort' => Stub::exactly(1, function() { })
|
'abort' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
// should call abort() method if shortcode action does not exist
|
// should call abort() method if shortcode action does not exist
|
||||||
$link = $clicks->processUrl(
|
$link = $clicks->processUrl(
|
||||||
|
@@ -38,7 +38,7 @@ class OpensTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItReturnsImageWhenTrackDataIsEmpty() {
|
function testItReturnsImageWhenTrackDataIsEmpty() {
|
||||||
$opens = Stub::make($this->opens, array(
|
$opens = Stub::make($this->opens, array(
|
||||||
'returnResponse' => Stub::exactly(1, function() { })
|
'returnResponse' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$opens->track(false);
|
$opens->track(false);
|
||||||
expect(StatisticsOpens::findMany())->isEmpty();
|
expect(StatisticsOpens::findMany())->isEmpty();
|
||||||
@@ -49,7 +49,7 @@ class OpensTest extends MailPoetTest {
|
|||||||
$data->subscriber->wp_user_id = 99;
|
$data->subscriber->wp_user_id = 99;
|
||||||
$data->preview = true;
|
$data->preview = true;
|
||||||
$opens = Stub::make($this->opens, array(
|
$opens = Stub::make($this->opens, array(
|
||||||
'returnResponse' => function() { }
|
'returnResponse' => null
|
||||||
), $this);
|
), $this);
|
||||||
$opens->track($data);
|
$opens->track($data);
|
||||||
expect(StatisticsOpens::findMany())->isEmpty();
|
expect(StatisticsOpens::findMany())->isEmpty();
|
||||||
@@ -61,7 +61,7 @@ class OpensTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItTracksOpenEvent() {
|
function testItTracksOpenEvent() {
|
||||||
$opens = Stub::make($this->opens, array(
|
$opens = Stub::make($this->opens, array(
|
||||||
'returnResponse' => function() { }
|
'returnResponse' => null
|
||||||
), $this);
|
), $this);
|
||||||
$opens->track($this->track_data);
|
$opens->track($this->track_data);
|
||||||
expect(StatisticsOpens::findMany())->notEmpty();
|
expect(StatisticsOpens::findMany())->notEmpty();
|
||||||
@@ -69,7 +69,7 @@ class OpensTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItDoesNotTrackRepeatedOpenEvents() {
|
function testItDoesNotTrackRepeatedOpenEvents() {
|
||||||
$opens = Stub::make($this->opens, array(
|
$opens = Stub::make($this->opens, array(
|
||||||
'returnResponse' => function() { }
|
'returnResponse' => null
|
||||||
), $this);
|
), $this);
|
||||||
for($count = 0; $count <= 2; $count++) {
|
for($count = 0; $count <= 2; $count++) {
|
||||||
$opens->track($this->track_data);
|
$opens->track($this->track_data);
|
||||||
@@ -79,7 +79,7 @@ class OpensTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItReturnsImageAfterTracking() {
|
function testItReturnsImageAfterTracking() {
|
||||||
$opens = Stub::make($this->opens, array(
|
$opens = Stub::make($this->opens, array(
|
||||||
'returnResponse' => Stub::exactly(1, function() { })
|
'returnResponse' => Stub::exactly(1)
|
||||||
), $this);
|
), $this);
|
||||||
$opens->track($this->track_data);
|
$opens->track($this->track_data);
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,9 @@ class SubscriptionFormSubmissionTest extends MailPoetTest {
|
|||||||
|
|
||||||
function testItSubscribesAndRedirectsBackWithSuccessResponse() {
|
function testItSubscribesAndRedirectsBackWithSuccessResponse() {
|
||||||
$mock = Mock::double('MailPoet\Util\Url', [
|
$mock = Mock::double('MailPoet\Util\Url', [
|
||||||
'redirectBack' => function($params) { return $params; }
|
'redirectBack' => function($params) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
$result = Form::onSubmit($this->request_data);
|
$result = Form::onSubmit($this->request_data);
|
||||||
expect(SubscriberModel::findOne($this->request_data['data']['email']))->notEmpty();
|
expect(SubscriberModel::findOne($this->request_data['data']['email']))->notEmpty();
|
||||||
@@ -70,7 +72,9 @@ class SubscriptionFormSubmissionTest extends MailPoetTest {
|
|||||||
$form->settings = serialize($form_settings);
|
$form->settings = serialize($form_settings);
|
||||||
$form->save();
|
$form->save();
|
||||||
$mock = Mock::double('MailPoet\Util\Url', [
|
$mock = Mock::double('MailPoet\Util\Url', [
|
||||||
'redirectTo' => function($params) { return $params; }
|
'redirectTo' => function($params) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
$result = Form::onSubmit($this->request_data);
|
$result = Form::onSubmit($this->request_data);
|
||||||
expect(SubscriberModel::findOne($this->request_data['data']['email']))->notEmpty();
|
expect(SubscriberModel::findOne($this->request_data['data']['email']))->notEmpty();
|
||||||
@@ -83,7 +87,9 @@ class SubscriptionFormSubmissionTest extends MailPoetTest {
|
|||||||
$request_data = $this->request_data;
|
$request_data = $this->request_data;
|
||||||
$request_data['data']['email'] = false;
|
$request_data['data']['email'] = false;
|
||||||
$mock = Mock::double('MailPoet\Util\Url', [
|
$mock = Mock::double('MailPoet\Util\Url', [
|
||||||
'redirectBack' => function($params) { return $params; }
|
'redirectBack' => function($params) {
|
||||||
|
return $params;
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
$result = Form::onSubmit($request_data);
|
$result = Form::onSubmit($request_data);
|
||||||
expect(SubscriberModel::findMany())->isEmpty();
|
expect(SubscriberModel::findMany())->isEmpty();
|
||||||
|
Reference in New Issue
Block a user