Rename initApi() to init() in workers [PREMIUM-4]
This commit is contained in:
@ -21,7 +21,7 @@ class Bounce extends SimpleWorker {
|
|||||||
|
|
||||||
public $api;
|
public $api;
|
||||||
|
|
||||||
function initApi() {
|
function init() {
|
||||||
if(!$this->api) {
|
if(!$this->api) {
|
||||||
$mailer_config = Mailer::getMailerConfig();
|
$mailer_config = Mailer::getMailerConfig();
|
||||||
$this->api = new API($mailer_config['mailpoet_api_key']);
|
$this->api = new API($mailer_config['mailpoet_api_key']);
|
||||||
|
@ -13,7 +13,7 @@ abstract class KeyCheckWorker extends SimpleWorker {
|
|||||||
|
|
||||||
public $bridge;
|
public $bridge;
|
||||||
|
|
||||||
function initApi() {
|
function init() {
|
||||||
if(!$this->bridge) {
|
if(!$this->bridge) {
|
||||||
$this->bridge = new Bridge();
|
$this->bridge = new Bridge();
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,6 @@ abstract class SimpleWorker {
|
|||||||
CronHelper::enforceExecutionLimit($this->timer);
|
CronHelper::enforceExecutionLimit($this->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
|
||||||
if(is_callable(array($this, 'initApi'))) {
|
|
||||||
$this->initApi();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkProcessingRequirements() {
|
function checkProcessingRequirements() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -34,7 +28,9 @@ abstract class SimpleWorker {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->init();
|
if(is_callable(array($this, 'init'))) {
|
||||||
|
$this->init();
|
||||||
|
}
|
||||||
|
|
||||||
$scheduled_queues = self::getScheduledQueues();
|
$scheduled_queues = self::getScheduledQueues();
|
||||||
$running_queues = self::getRunningQueues();
|
$running_queues = self::getRunningQueues();
|
||||||
|
@ -38,7 +38,7 @@ class BounceTest extends MailPoetTest {
|
|||||||
function testItCanInitializeBridgeAPI() {
|
function testItCanInitializeBridgeAPI() {
|
||||||
$this->setMailPoetSendingMethod();
|
$this->setMailPoetSendingMethod();
|
||||||
$worker = new Bounce(microtime(true));
|
$worker = new Bounce(microtime(true));
|
||||||
$worker->initApi();
|
$worker->init();
|
||||||
expect($worker->api instanceof API)->true();
|
expect($worker->api instanceof API)->true();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class KeyCheckWorkerTest extends MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testItCanInitializeBridgeAPI() {
|
function testItCanInitializeBridgeAPI() {
|
||||||
$this->worker->initApi();
|
$this->worker->init();
|
||||||
expect($this->worker->bridge instanceof Bridge)->true();
|
expect($this->worker->bridge instanceof Bridge)->true();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ if(!defined('ABSPATH')) exit;
|
|||||||
class MockSimpleWorker extends SimpleWorker {
|
class MockSimpleWorker extends SimpleWorker {
|
||||||
const TASK_TYPE = 'mock_simple_worker';
|
const TASK_TYPE = 'mock_simple_worker';
|
||||||
|
|
||||||
function initApi() {
|
function init() {
|
||||||
// to be mocked
|
// to be mocked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,10 @@ class SimpleWorkerTest extends MailPoetTest {
|
|||||||
expect($worker->process())->false();
|
expect($worker->process())->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItCanInitAPIBeforeProcessing() {
|
function testItCanInitBeforeProcessing() {
|
||||||
$worker = Stub::make(
|
$worker = Stub::make(
|
||||||
$this->worker,
|
$this->worker,
|
||||||
array('initApi' => Stub::once()),
|
array('init' => Stub::once()),
|
||||||
$this
|
$this
|
||||||
);
|
);
|
||||||
$worker->process();
|
$worker->process();
|
||||||
|
Reference in New Issue
Block a user