Add missing this for stubs expecting a number of method calls to work

This commit is contained in:
stoletniy
2017-06-21 19:14:17 +03:00
committed by pavel-mailpoet
parent 0e5401dd68
commit 6ff3895940
5 changed files with 27 additions and 14 deletions

View File

@ -18,7 +18,8 @@ class InstallerTest extends MailPoetTest {
$this->installer, $this->installer,
array( array(
'getPluginInformation' => Stub::once() 'getPluginInformation' => Stub::once()
) ),
$this
); );
$installer->init(); $installer->init();
apply_filters('plugins_api', null, null, null); apply_filters('plugins_api', null, null, null);
@ -51,7 +52,8 @@ class InstallerTest extends MailPoetTest {
$obj->package = $obj->download_link; $obj->package = $obj->download_link;
return $obj; return $obj;
} }
) ),
$this
); );
$result = $installer->getPluginInformation(false, 'plugin_information', $args); $result = $installer->getPluginInformation(false, 'plugin_information', $args);
expect($result->slug)->equals($this->slug); expect($result->slug)->equals($this->slug);

View File

@ -50,7 +50,8 @@ class RendererTest extends MailPoetTest {
'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
), ),
) )
); );
@ -69,7 +70,8 @@ class RendererTest extends MailPoetTest {
'render' => Stub::atLeastOnce(function() use ($exception_message) { 'render' => Stub::atLeastOnce(function() use ($exception_message) {
throw new \RuntimeException($exception_message); throw new \RuntimeException($exception_message);
}), }),
) ),
$this
), ),
) )
); );

View File

@ -21,7 +21,8 @@ class UpdaterTest extends MailPoetTest {
$this->updater, $this->updater,
array( array(
'checkForUpdate' => Stub::once() 'checkForUpdate' => Stub::once()
) ),
$this
); );
$updater->init(); $updater->init();
apply_filters('pre_set_site_transient_update_plugins', null); apply_filters('pre_set_site_transient_update_plugins', null);
@ -48,7 +49,8 @@ class UpdaterTest extends MailPoetTest {
'package' => home_url() . '/wp-content/uploads/mailpoet-premium.zip' 'package' => home_url() . '/wp-content/uploads/mailpoet-premium.zip'
); );
} }
) ),
$this
); );
$result = $updater->checkForUpdate($update_transient); $result = $updater->checkForUpdate($update_transient);
expect($result->last_checked)->greaterOrEquals($update_transient->last_checked); expect($result->last_checked)->greaterOrEquals($update_transient->last_checked);

View File

@ -220,7 +220,8 @@ class SendingQueueTest extends MailPoetTest {
expect($extra_params['unsubscribe_url'])->equals($directUnsubscribeURL); expect($extra_params['unsubscribe_url'])->equals($directUnsubscribeURL);
return true; return true;
}) })
) ),
$this
) )
); );
$sending_queue_worker->process(); $sending_queue_worker->process();
@ -239,7 +240,8 @@ class SendingQueueTest extends MailPoetTest {
expect($extra_params['unsubscribe_url'])->equals($trackedUnsubscribeURL); expect($extra_params['unsubscribe_url'])->equals($trackedUnsubscribeURL);
return true; return true;
}) })
) ),
$this
) )
); );
$sending_queue_worker->process(); $sending_queue_worker->process();
@ -257,7 +259,8 @@ class SendingQueueTest extends MailPoetTest {
expect(!empty($newsletter['body']['text']))->true(); expect(!empty($newsletter['body']['text']))->true();
return true; return true;
}) })
) ),
$this
) )
); );
$sending_queue_worker->process(); $sending_queue_worker->process();
@ -303,7 +306,8 @@ class SendingQueueTest extends MailPoetTest {
return true; return true;
}), }),
'getProcessingMethod' => Stub::exactly(1, function() { return 'bulk'; }) 'getProcessingMethod' => Stub::exactly(1, function() { return 'bulk'; })
) ),
$this
) )
); );
$sending_queue_worker->process(); $sending_queue_worker->process();
@ -351,7 +355,8 @@ class SendingQueueTest extends MailPoetTest {
expect(!empty($newsletter['body']['text']))->true(); expect(!empty($newsletter['body']['text']))->true();
return true; return true;
}) })
) ),
$this
) )
); );
$sending_queue_worker->process(); $sending_queue_worker->process();
@ -400,7 +405,8 @@ 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($newsletter, $subscriber) { return true; })),
$this
); );
$sending_queue_worker->process(); $sending_queue_worker->process();
@ -438,7 +444,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' => Stub::exactly(1, function($newsletter, $subscriber) { return true; })) array('send' => function($newsletter, $subscriber) { return true; })
); );
$sending_queue_worker->process(); $sending_queue_worker->process();

View File

@ -107,7 +107,8 @@ 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($newsletter, $subscriber) { return true; })),
$this
) )
) )
); );