Add public keyword to methods
[MAILPOET-2413]
This commit is contained in:
@@ -17,7 +17,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
/** @var CronHelper */
|
||||
private $cron_helper;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->settings = SettingsController::getInstance();
|
||||
$this->settings->set('db_version', MAILPOET_VERSION);
|
||||
@@ -32,13 +32,13 @@ class CronHelperTest extends \MailPoetTest {
|
||||
$this->cron_helper = new CronHelper($this->settings, new WPFunctions);
|
||||
}
|
||||
|
||||
function testItDefinesConstants() {
|
||||
public function testItDefinesConstants() {
|
||||
expect(CronHelper::DAEMON_EXECUTION_LIMIT)->equals(20);
|
||||
expect(CronHelper::DAEMON_REQUEST_TIMEOUT)->equals(5);
|
||||
expect(CronHelper::DAEMON_SETTING)->equals('cron_daemon');
|
||||
}
|
||||
|
||||
function testItCreatesDaemon() {
|
||||
public function testItCreatesDaemon() {
|
||||
$token = 'create_token';
|
||||
$time = time();
|
||||
$this->cron_helper->createDaemon($token);
|
||||
@@ -57,7 +57,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItRestartsDaemon() {
|
||||
public function testItRestartsDaemon() {
|
||||
$token = 'restart_token';
|
||||
$time = time();
|
||||
$this->cron_helper->restartDaemon($token);
|
||||
@@ -76,7 +76,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItLoadsDaemon() {
|
||||
public function testItLoadsDaemon() {
|
||||
$daemon = $this->getDeamonTestData();
|
||||
$this->settings->set(
|
||||
CronHelper::DAEMON_SETTING,
|
||||
@@ -85,7 +85,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect($this->cron_helper->getDaemon())->equals($daemon);
|
||||
}
|
||||
|
||||
function testItSavesDaemon() {
|
||||
public function testItSavesDaemon() {
|
||||
// when saving daemon, 'updated_at' value should change
|
||||
$daemon = $this->getDeamonTestData();
|
||||
$this->settings->set(
|
||||
@@ -98,7 +98,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect($this->cron_helper->getDaemon())->equals($daemon);
|
||||
}
|
||||
|
||||
function testItUpdatesDaemonAccessedAt() {
|
||||
public function testItUpdatesDaemonAccessedAt() {
|
||||
$daemon = $this->getDeamonTestData();
|
||||
$this->settings->set(
|
||||
CronHelper::DAEMON_SETTING,
|
||||
@@ -115,7 +115,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect($updated_daemon['run_accessed_at'])->lessThan($time + 2);
|
||||
}
|
||||
|
||||
function testItThrowsAnExceptionIfAccessingNonExistingDaemon() {
|
||||
public function testItThrowsAnExceptionIfAccessingNonExistingDaemon() {
|
||||
try {
|
||||
$this->cron_helper->accessDaemon('some_token');
|
||||
$this->fail('An exception should have been thrown.');
|
||||
@@ -124,7 +124,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItDetectsNotAccessibleDaemon() {
|
||||
public function testItDetectsNotAccessibleDaemon() {
|
||||
$time = time();
|
||||
$run_start_values = [null, $time - 20];
|
||||
foreach ($run_start_values as $run_start) {
|
||||
@@ -139,7 +139,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItDetectsAccessibleDaemon() {
|
||||
public function testItDetectsAccessibleDaemon() {
|
||||
$time = time();
|
||||
$daemon = $this->getDeamonTestData();
|
||||
$daemon['run_accessed_at'] = $time - 5;
|
||||
@@ -151,7 +151,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect($this->cron_helper->isDaemonAccessible())->true();
|
||||
}
|
||||
|
||||
function testItDetectsUnknownStateOfTheDaemon() {
|
||||
public function testItDetectsUnknownStateOfTheDaemon() {
|
||||
$time = time();
|
||||
$test_inputs = [
|
||||
[
|
||||
@@ -180,7 +180,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItDeactivatesDaemon() {
|
||||
public function testItDeactivatesDaemon() {
|
||||
$daemon = $this->getDeamonTestData();
|
||||
$this->settings->set(
|
||||
CronHelper::DAEMON_SETTING,
|
||||
@@ -192,7 +192,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect($daemon['status'])->equals(CronHelper::DAEMON_STATUS_INACTIVE);
|
||||
}
|
||||
|
||||
function testItSavesLastError() {
|
||||
public function testItSavesLastError() {
|
||||
$daemon = $this->getDeamonTestData();
|
||||
$this->settings->set(
|
||||
CronHelper::DAEMON_SETTING,
|
||||
@@ -207,7 +207,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
|
||||
function testItSavesRunCompletedAt() {
|
||||
public function testItSavesRunCompletedAt() {
|
||||
$daemon = $this->getDeamonTestData();
|
||||
$this->settings->set(
|
||||
CronHelper::DAEMON_SETTING,
|
||||
@@ -219,7 +219,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect($daemon['run_completed_at'])->equals(123);
|
||||
}
|
||||
|
||||
function testItCreatesRandomToken() {
|
||||
public function testItCreatesRandomToken() {
|
||||
// random token is a string of 5 characters
|
||||
$token1 = $this->cron_helper->createToken();
|
||||
$token2 = $this->cron_helper->createToken();
|
||||
@@ -228,7 +228,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect(strlen($token1))->equals(5);
|
||||
}
|
||||
|
||||
function testItGetsSiteUrl() {
|
||||
public function testItGetsSiteUrl() {
|
||||
// 1. do nothing when the url does not contain port
|
||||
$site_url = 'http://example.com';
|
||||
expect($this->cron_helper->getSiteUrl($site_url))->equals($site_url);
|
||||
@@ -254,13 +254,13 @@ class CronHelperTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItGetsSubsiteUrlOnMultisiteEnvironment() {
|
||||
public function testItGetsSubsiteUrlOnMultisiteEnvironment() {
|
||||
if ((boolean)getenv('MULTISITE') === true) {
|
||||
expect($this->cron_helper->getSiteUrl())->contains(getenv('WP_TEST_MULTISITE_SLUG'));
|
||||
}
|
||||
}
|
||||
|
||||
function testItEnforcesExecutionLimit() {
|
||||
public function testItEnforcesExecutionLimit() {
|
||||
$time = microtime(true);
|
||||
expect($this->cron_helper->enforceExecutionLimit($time))->null();
|
||||
try {
|
||||
@@ -271,7 +271,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItAllowsSettingCustomCronUrl() {
|
||||
public function testItAllowsSettingCustomCronUrl() {
|
||||
$filter = function($url) {
|
||||
expect($url)->contains('&endpoint=cron');
|
||||
return 'http://custom_cron_url';
|
||||
@@ -281,7 +281,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
remove_filter('mailpoet_cron_request_url', $filter);
|
||||
}
|
||||
|
||||
function testItAllowsSettingCustomCronRequestArguments() {
|
||||
public function testItAllowsSettingCustomCronRequestArguments() {
|
||||
$request_args = [
|
||||
'blocking' => 'custom_blocking',
|
||||
'sslverify' => 'custom_ssl_verify',
|
||||
@@ -306,7 +306,7 @@ class CronHelperTest extends \MailPoetTest {
|
||||
$wp->removeFilter('mailpoet_cron_request_args', $filter);
|
||||
}
|
||||
|
||||
function testItReturnsErrorMessageAsPingResponseWhenCronUrlCannotBeAccessed() {
|
||||
public function testItReturnsErrorMessageAsPingResponseWhenCronUrlCannotBeAccessed() {
|
||||
$wp = Stub::make(new WPFunctions, [
|
||||
'applyFilters' => [],
|
||||
]);
|
||||
@@ -314,18 +314,18 @@ class CronHelperTest extends \MailPoetTest {
|
||||
expect($cron_helper->pingDaemon())->equals('A valid URL was not provided.');
|
||||
}
|
||||
|
||||
function testItPingsDaemon() {
|
||||
public function testItPingsDaemon() {
|
||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped();
|
||||
// raw response is returned
|
||||
expect($this->cron_helper->pingDaemon())->equals(DaemonHttpRunner::PING_SUCCESS_RESPONSE);
|
||||
}
|
||||
|
||||
function testItValidatesPingResponse() {
|
||||
public function testItValidatesPingResponse() {
|
||||
expect($this->cron_helper->validatePingResponse('pong'))->true();
|
||||
expect($this->cron_helper->validatePingResponse('something else'))->false();
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
}
|
||||
|
||||
|
@@ -20,13 +20,13 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
/** @var CronHelper */
|
||||
private $cron_helper;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
$this->cron_worker_runner = $this->di_container->get(CronWorkerRunner::class);
|
||||
$this->cron_helper = $this->di_container->get(CronHelper::class);
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
|
||||
function testItCanInitBeforeProcessing() {
|
||||
public function testItCanInitBeforeProcessing() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'init' => Expected::once(),
|
||||
'scheduleAutomatically' => Expected::once(false),
|
||||
@@ -34,7 +34,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
$this->cron_worker_runner->run($worker);
|
||||
}
|
||||
|
||||
function testItPreparesTask() {
|
||||
public function testItPreparesTask() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'prepareTaskStrategy' => Expected::once(true),
|
||||
'processTaskStrategy' => Expected::never(),
|
||||
@@ -46,7 +46,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
expect(ScheduledTask::findOne($task->id)->status)->null();
|
||||
}
|
||||
|
||||
function testItProcessesTask() {
|
||||
public function testItProcessesTask() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'prepareTaskStrategy' => Expected::never(),
|
||||
'processTaskStrategy' => Expected::once(true),
|
||||
@@ -58,7 +58,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
expect(ScheduledTask::findOne($task->id)->status)->same(ScheduledTask::STATUS_COMPLETED);
|
||||
}
|
||||
|
||||
function testItFailsToProcessWithoutTasks() {
|
||||
public function testItFailsToProcessWithoutTasks() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'scheduleAutomatically' => Expected::once(false),
|
||||
'prepareTaskStrategy' => Expected::never(),
|
||||
@@ -69,7 +69,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
expect($result)->false();
|
||||
}
|
||||
|
||||
function testItFailsToProcessWithoutProcessingRequirementsMet() {
|
||||
public function testItFailsToProcessWithoutProcessingRequirementsMet() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'checkProcessingRequirements' => Expected::once(false),
|
||||
'prepareTaskStrategy' => Expected::never(),
|
||||
@@ -83,7 +83,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
expect($result)->false();
|
||||
}
|
||||
|
||||
function testItCanScheduleTaskAutomatically() {
|
||||
public function testItCanScheduleTaskAutomatically() {
|
||||
$in_one_week = Carbon::now()->addWeek()->startOfDay();
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'scheduleAutomatically' => Expected::once(true),
|
||||
@@ -96,7 +96,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
expect(ScheduledTask::findOne()->scheduled_at)->same($in_one_week->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
function testItWillRescheduleTaskIfItIsRunningForTooLong() {
|
||||
public function testItWillRescheduleTaskIfItIsRunningForTooLong() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'processTaskStrategy' => Expected::once(false),
|
||||
]);
|
||||
@@ -122,7 +122,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
expect($task->in_progress)->isEmpty();
|
||||
}
|
||||
|
||||
function testItWillRescheduleATaskIfItFails() {
|
||||
public function testItWillRescheduleATaskIfItFails() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'processTaskStrategy' => Expected::once(function () {
|
||||
throw new \Exception('test error');
|
||||
@@ -144,7 +144,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testWillNotRescheduleATaskOnCronTimeout() {
|
||||
public function testWillNotRescheduleATaskOnCronTimeout() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'processTaskStrategy' => Expected::once(function () {
|
||||
$this->cron_helper->enforceExecutionLimit(microtime(true) - CronHelper::DAEMON_EXECUTION_LIMIT - 1);
|
||||
@@ -165,7 +165,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItWillNotRunInMultipleInstances() {
|
||||
public function testItWillNotRunInMultipleInstances() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'supportsMultipleInstances' => Expected::once(false),
|
||||
'processTaskStrategy' => Expected::never(),
|
||||
@@ -178,7 +178,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
$this->cron_worker_runner->run($worker);
|
||||
}
|
||||
|
||||
function testItThrowsExceptionWhenExecutionLimitIsReached() {
|
||||
public function testItThrowsExceptionWhenExecutionLimitIsReached() {
|
||||
$worker = $this->make(SimpleWorkerMockImplementation::class, [
|
||||
'processTaskStrategy' => Expected::never(),
|
||||
]);
|
||||
@@ -212,7 +212,7 @@ class CronWorkerRunnerTest extends \MailPoetTest {
|
||||
return $task;
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
}
|
||||
|
@@ -13,12 +13,12 @@ class CronWorkerSchedulerTest extends \MailPoetTest {
|
||||
/** @var CronWorkerScheduler */
|
||||
private $cron_worker_scheduler;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
$this->cron_worker_scheduler = $this->di_container->get(CronWorkerScheduler::class);
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
|
||||
function testItSchedulesTask() {
|
||||
public function testItSchedulesTask() {
|
||||
$next_run_date = Carbon::now()->addWeek();
|
||||
$this->cron_worker_scheduler->schedule('test', $next_run_date);
|
||||
|
||||
@@ -29,7 +29,7 @@ class CronWorkerSchedulerTest extends \MailPoetTest {
|
||||
expect($tasks[0]->scheduled_at)->same($next_run_date->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
function testItDoesNotScheduleTaskTwice() {
|
||||
public function testItDoesNotScheduleTaskTwice() {
|
||||
$next_run_date = Carbon::now()->addWeek();
|
||||
$this->cron_worker_scheduler->schedule('test', $next_run_date);
|
||||
expect(ScheduledTask::findMany())->count(1);
|
||||
@@ -39,7 +39,7 @@ class CronWorkerSchedulerTest extends \MailPoetTest {
|
||||
expect(ScheduledTask::findMany())->count(1);
|
||||
}
|
||||
|
||||
function testItReschedulesTask() {
|
||||
public function testItReschedulesTask() {
|
||||
$next_run_date = Carbon::now()->subDay();
|
||||
$task = $this->cron_worker_scheduler->schedule('test', $next_run_date);
|
||||
$this->cron_worker_scheduler->reschedule($task, 10);
|
||||
@@ -52,7 +52,7 @@ class CronWorkerSchedulerTest extends \MailPoetTest {
|
||||
expect($tasks[0]->scheduled_at)->greaterThan(Carbon::now());
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
}
|
||||
|
@@ -23,13 +23,13 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
/** @var SettingsController */
|
||||
private $settings;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->settings = SettingsController::getInstance();
|
||||
$this->cron_helper = ContainerWrapper::getInstance()->get(CronHelper::class);
|
||||
}
|
||||
|
||||
function testItConstructs() {
|
||||
public function testItConstructs() {
|
||||
$this->settings->set(
|
||||
CronHelper::DAEMON_SETTING,
|
||||
[]
|
||||
@@ -39,7 +39,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect(strlen($daemon->token))->greaterOrEquals(5);
|
||||
}
|
||||
|
||||
function testItDoesNotRunWithoutRequestData() {
|
||||
public function testItDoesNotRunWithoutRequestData() {
|
||||
$daemon = $this->make(
|
||||
DaemonHttpRunner::class,
|
||||
[
|
||||
@@ -51,7 +51,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect($daemon->run(false))->equals('Invalid or missing request data.');
|
||||
}
|
||||
|
||||
function testItDoesNotRunWhenThereIsInvalidOrMissingToken() {
|
||||
public function testItDoesNotRunWhenThereIsInvalidOrMissingToken() {
|
||||
$daemon = $this->make(
|
||||
DaemonHttpRunner::class,
|
||||
[
|
||||
@@ -66,7 +66,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect($daemon->run(['token' => 456]))->equals('Invalid or missing token.');
|
||||
}
|
||||
|
||||
function testItStoresErrorMessageAndContinuesExecutionWhenWorkersThrowException() {
|
||||
public function testItStoresErrorMessageAndContinuesExecutionWhenWorkersThrowException() {
|
||||
$data = [
|
||||
'token' => 123,
|
||||
];
|
||||
@@ -94,7 +94,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect($updated_daemon['last_error'][1]['message'])->equals('');
|
||||
}
|
||||
|
||||
function testItCanPauseExecution() {
|
||||
public function testItCanPauseExecution() {
|
||||
$daemon = $this->makeEmpty(Daemon::class);
|
||||
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
||||
'pauseExecution' => Expected::exactly(1, function($pause_delay) {
|
||||
@@ -113,7 +113,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
|
||||
function testItTerminatesExecutionWhenDaemonIsDeleted() {
|
||||
public function testItTerminatesExecutionWhenDaemonIsDeleted() {
|
||||
$daemon = $this->make(Daemon::class, [
|
||||
'run' => function () {
|
||||
$this->settings->delete(CronHelper::DAEMON_SETTING);
|
||||
@@ -134,7 +134,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
$daemon_http_runner->run($data);
|
||||
}
|
||||
|
||||
function testItTerminatesExecutionWhenDaemonTokenChangesAndKeepsChangedToken() {
|
||||
public function testItTerminatesExecutionWhenDaemonTokenChangesAndKeepsChangedToken() {
|
||||
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
||||
'pauseExecution' => null,
|
||||
'terminateRequest' => Expected::exactly(1),
|
||||
@@ -159,7 +159,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect($data_after_run['token'])->equals(567);
|
||||
}
|
||||
|
||||
function testItTerminatesExecutionWhenDaemonIsDeactivated() {
|
||||
public function testItTerminatesExecutionWhenDaemonIsDeactivated() {
|
||||
$daemon = $this->make(DaemonHttpRunner::class, [
|
||||
'pauseExecution' => null,
|
||||
'terminateRequest' => Expected::exactly(1),
|
||||
@@ -174,7 +174,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
$daemon->run($data);
|
||||
}
|
||||
|
||||
function testItTerminatesExecutionWhenWPTriggerStopsCron() {
|
||||
public function testItTerminatesExecutionWhenWPTriggerStopsCron() {
|
||||
$daemon = $this->make(Daemon::class, [
|
||||
'run' => null,
|
||||
]);
|
||||
@@ -195,7 +195,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
WPFunctions::get()->removeAllFilters('mailpoet_cron_enable_self_deactivation');
|
||||
}
|
||||
|
||||
function testItUpdatesDaemonTokenDuringExecution() {
|
||||
public function testItUpdatesDaemonTokenDuringExecution() {
|
||||
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
||||
'pauseExecution' => null,
|
||||
'callSelf' => null,
|
||||
@@ -215,7 +215,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect($updated_daemon['token'])->equals($daemon_http_runner->token);
|
||||
}
|
||||
|
||||
function testItUpdatesTimestampsDuringExecution() {
|
||||
public function testItUpdatesTimestampsDuringExecution() {
|
||||
$cron_worker_runner_mock = $this->createMock(CronWorkerRunner::class);
|
||||
$cron_worker_runner_mock
|
||||
->expects($this->at(0))
|
||||
@@ -247,7 +247,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect($updated_daemon['run_completed_at'])->lessThan($now + 4);
|
||||
}
|
||||
|
||||
function testItCanRun() {
|
||||
public function testItCanRun() {
|
||||
ignore_user_abort(0);
|
||||
expect(ignore_user_abort())->equals(0);
|
||||
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
||||
@@ -270,7 +270,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
expect(ignore_user_abort())->equals(1);
|
||||
}
|
||||
|
||||
function testItRespondsToPingRequest() {
|
||||
public function testItRespondsToPingRequest() {
|
||||
$daemon = $this->make(DaemonHttpRunner::class, [
|
||||
'terminateRequest' => Expected::exactly(1, function($message) {
|
||||
expect($message)->equals('pong');
|
||||
@@ -279,7 +279,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
$daemon->ping();
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class DaemonTest extends \MailPoetTest {
|
||||
$this->cron_helper = ContainerWrapper::getInstance()->get(CronHelper::class);
|
||||
}
|
||||
|
||||
function testItCanRun() {
|
||||
public function testItCanRun() {
|
||||
$cron_worker_runner = $this->make(CronWorkerRunner::class, [
|
||||
'run' => null,
|
||||
]);
|
||||
@@ -35,7 +35,7 @@ class DaemonTest extends \MailPoetTest {
|
||||
$daemon->run($data);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ class SupervisorTest extends \MailPoetTest {
|
||||
/** @var SettingsController */
|
||||
private $settings;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
// cron trigger is by default set to 'WordPress'; when it runs and does not
|
||||
// detect any queues to process, it deletes the daemon setting, so Supervisor and
|
||||
@@ -26,34 +26,34 @@ class SupervisorTest extends \MailPoetTest {
|
||||
$this->supervisor = ContainerWrapper::getInstance()->get(Supervisor::class);
|
||||
}
|
||||
|
||||
function testItCanBeInitialized() {
|
||||
public function testItCanBeInitialized() {
|
||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped();
|
||||
$this->supervisor->init();
|
||||
expect($this->supervisor->token)->notEmpty();
|
||||
expect($this->supervisor->daemon)->notEmpty();
|
||||
}
|
||||
|
||||
function testItCreatesDaemonWhenOneDoesNotExist() {
|
||||
public function testItCreatesDaemonWhenOneDoesNotExist() {
|
||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped();
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING))->null();
|
||||
$this->supervisor->init();
|
||||
expect($this->supervisor->getDaemon())->notEmpty();
|
||||
}
|
||||
|
||||
function testItReturnsDaemonWhenOneExists() {
|
||||
public function testItReturnsDaemonWhenOneExists() {
|
||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped();
|
||||
$this->supervisor->init();
|
||||
expect($this->supervisor->getDaemon())->equals($this->supervisor->daemon);
|
||||
}
|
||||
|
||||
function testItDoesNothingWhenDaemonExecutionDurationIsBelowLimit() {
|
||||
public function testItDoesNothingWhenDaemonExecutionDurationIsBelowLimit() {
|
||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped();
|
||||
$this->supervisor->init();
|
||||
expect($this->supervisor->checkDaemon())
|
||||
->equals($this->supervisor->daemon);
|
||||
}
|
||||
|
||||
function testRestartsDaemonWhenExecutionDurationIsAboveLimit() {
|
||||
public function testRestartsDaemonWhenExecutionDurationIsAboveLimit() {
|
||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped();
|
||||
$this->supervisor->init();
|
||||
$this->supervisor->daemon['updated_at'] = time() - $this->cron_helper->getDaemonExecutionTimeout();
|
||||
@@ -63,7 +63,7 @@ class SupervisorTest extends \MailPoetTest {
|
||||
expect($daemon['status'])->equals(CronHelper::DAEMON_STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
function testRestartsDaemonWhenItIsInactive() {
|
||||
public function testRestartsDaemonWhenItIsInactive() {
|
||||
if (getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') $this->markTestSkipped();
|
||||
$this->supervisor->init();
|
||||
$this->supervisor->daemon['updated_at'] = time();
|
||||
@@ -72,7 +72,7 @@ class SupervisorTest extends \MailPoetTest {
|
||||
expect($daemon['status'])->equals(CronHelper::DAEMON_STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ class MailPoetTest extends \MailPoetTest {
|
||||
/** @var SettingsController */
|
||||
private $settings;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
// cron trigger is by default set to 'WordPress'; when it runs and does not
|
||||
// detect any queues to process, it deletes the daemon setting, so Supervisor that's
|
||||
@@ -23,13 +23,13 @@ class MailPoetTest extends \MailPoetTest {
|
||||
]);
|
||||
}
|
||||
|
||||
function testItCanRun() {
|
||||
public function testItCanRun() {
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING))->null();
|
||||
$this->di_container->get(MailPoet::class)->run();
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING))->notEmpty();
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
/** @var WordPress */
|
||||
private $wordpress_trigger;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
// cron trigger is by default set to 'WordPress'; when it runs and does not
|
||||
// detect any queues to process, it deletes the daemon setting, so Supervisor that's
|
||||
@@ -42,7 +42,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
$this->wordpress_trigger = $this->di_container->get(WordPress::class);
|
||||
}
|
||||
|
||||
function testItDoesNotRunIfRunIntervalIsNotElapsed() {
|
||||
public function testItDoesNotRunIfRunIntervalIsNotElapsed() {
|
||||
$run_interval = 10;
|
||||
WPFunctions::get()->addFilter('mailpoet_cron_trigger_wordpress_run_interval', function () use ($run_interval) {
|
||||
return $run_interval;
|
||||
@@ -55,7 +55,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
WPFunctions::get()->removeAllFilters('mailpoet_cron_trigger_wordpress_run_interval');
|
||||
}
|
||||
|
||||
function testItRunsIfRunIntervalIsElapsed() {
|
||||
public function testItRunsIfRunIntervalIsElapsed() {
|
||||
$run_interval = 10;
|
||||
WPFunctions::get()->addFilter('mailpoet_cron_trigger_wordpress_run_interval', function () use ($run_interval) {
|
||||
return $run_interval;
|
||||
@@ -68,7 +68,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
WPFunctions::get()->removeAllFilters('mailpoet_cron_trigger_wordpress_run_interval');
|
||||
}
|
||||
|
||||
function testItCanResetRunInterval() {
|
||||
public function testItCanResetRunInterval() {
|
||||
$current_time = time();
|
||||
$this->settings->set(WordPress::LAST_RUN_AT_SETTING, $current_time);
|
||||
$this->_addQueue($status = SendingQueue::STATUS_SCHEDULED);
|
||||
@@ -77,13 +77,13 @@ class WordPressTest extends \MailPoetTest {
|
||||
expect($this->wordpress_trigger->run())->notEmpty();
|
||||
}
|
||||
|
||||
function testItRequiresScheduledQueuesToExecute() {
|
||||
public function testItRequiresScheduledQueuesToExecute() {
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->false();
|
||||
$this->_addQueue($status = SendingQueue::STATUS_SCHEDULED);
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
}
|
||||
|
||||
function testItRequiresRunningQueuesToExecute() {
|
||||
public function testItRequiresRunningQueuesToExecute() {
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->false();
|
||||
// status of 'null' indicates that queue is running
|
||||
$this->_addQueue($status = null);
|
||||
@@ -91,13 +91,13 @@ class WordPressTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
|
||||
function testItFailsExecutionRequiremenetsCheckWhenQueueStatusIsCompleted() {
|
||||
public function testItFailsExecutionRequiremenetsCheckWhenQueueStatusIsCompleted() {
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->false();
|
||||
$this->_addQueue($status = 'completed');
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->false();
|
||||
}
|
||||
|
||||
function testItRequiresSendingLimitNotToBeReachedToExecute() {
|
||||
public function testItRequiresSendingLimitNotToBeReachedToExecute() {
|
||||
$this->_addQueue($status = null);
|
||||
$this->_addMTAConfigAndLog($sent = null);
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
@@ -105,7 +105,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->false();
|
||||
}
|
||||
|
||||
function testItRequiresSendingNotToBePausedToExecute() {
|
||||
public function testItRequiresSendingNotToBePausedToExecute() {
|
||||
$this->_addQueue($status = null);
|
||||
$this->_addMTAConfigAndLog($sent = null);
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
@@ -113,36 +113,36 @@ class WordPressTest extends \MailPoetTest {
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->false();
|
||||
}
|
||||
|
||||
function testItExecutesWhenMigrationIsNotPresent() {
|
||||
public function testItExecutesWhenMigrationIsNotPresent() {
|
||||
$this->_enableMigration();
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
}
|
||||
|
||||
function testItExecutesWhenMigrationIsDue() {
|
||||
public function testItExecutesWhenMigrationIsDue() {
|
||||
$this->_enableMigration();
|
||||
$this->_addScheduledTask(MigrationWorker::TASK_TYPE, $status = ScheduledTask::STATUS_SCHEDULED);
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
}
|
||||
|
||||
function testItExecutesWhenAuthorizedEmailsCheckIsDue() {
|
||||
public function testItExecutesWhenAuthorizedEmailsCheckIsDue() {
|
||||
$this->_enableMigration();
|
||||
$this->_addScheduledTask(AuthorizedSendingEmailsCheck::TASK_TYPE, $status = ScheduledTask::STATUS_SCHEDULED);
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
}
|
||||
|
||||
function testItExecutesWhenBeamerTaskIsDue() {
|
||||
public function testItExecutesWhenBeamerTaskIsDue() {
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
$this->_addScheduledTask(Beamer::TASK_TYPE, $status = ScheduledTask::STATUS_SCHEDULED);
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
}
|
||||
|
||||
function testItDoesNotExecuteWhenMigrationIsCompleted() {
|
||||
public function testItDoesNotExecuteWhenMigrationIsCompleted() {
|
||||
$this->_enableMigration();
|
||||
$this->_addScheduledTask(MigrationWorker::TASK_TYPE, $status = ScheduledTask::STATUS_COMPLETED);
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->false();
|
||||
}
|
||||
|
||||
function testItExecutesWhenBounceIsActive() {
|
||||
public function testItExecutesWhenBounceIsActive() {
|
||||
$this->settings->set(Mailer::MAILER_CONFIG_SETTING_NAME, [
|
||||
'method' => Mailer::METHOD_MAILPOET,
|
||||
'frequency' => [
|
||||
@@ -154,14 +154,14 @@ class WordPressTest extends \MailPoetTest {
|
||||
expect($this->wordpress_trigger->checkExecutionRequirements())->true();
|
||||
}
|
||||
|
||||
function testItCanDeactivateRunningDaemon() {
|
||||
public function testItCanDeactivateRunningDaemon() {
|
||||
$this->settings->set(CronHelper::DAEMON_SETTING, ['status' => CronHelper::DAEMON_STATUS_ACTIVE]);
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING)['status'])->equals(CronHelper::DAEMON_STATUS_ACTIVE);
|
||||
$this->wordpress_trigger->stop();
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING)['status'])->equals(CronHelper::DAEMON_STATUS_INACTIVE);
|
||||
}
|
||||
|
||||
function testItRunsWhenExecutionRequirementsAreMet() {
|
||||
public function testItRunsWhenExecutionRequirementsAreMet() {
|
||||
// status of 'null' indicates that queue is running
|
||||
$this->_addQueue($status = null);
|
||||
// check that cron daemon does not exist
|
||||
@@ -170,14 +170,14 @@ class WordPressTest extends \MailPoetTest {
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING))->notNull();
|
||||
}
|
||||
|
||||
function testItDeactivatesCronDaemonWhenExecutionRequirementsAreNotMet() {
|
||||
public function testItDeactivatesCronDaemonWhenExecutionRequirementsAreNotMet() {
|
||||
$this->settings->set(CronHelper::DAEMON_SETTING, ['status' => CronHelper::DAEMON_STATUS_ACTIVE]);
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING)['status'])->equals(CronHelper::DAEMON_STATUS_ACTIVE);
|
||||
$this->wordpress_trigger->run();
|
||||
expect($this->settings->get(CronHelper::DAEMON_SETTING)['status'])->equals(CronHelper::DAEMON_STATUS_INACTIVE);
|
||||
}
|
||||
|
||||
function _addMTAConfigAndLog($sent, $status = null) {
|
||||
public function _addMTAConfigAndLog($sent, $status = null) {
|
||||
$mta_config = [
|
||||
'frequency' => [
|
||||
'emails' => 1,
|
||||
@@ -199,7 +199,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function _addQueue($status) {
|
||||
public function _addQueue($status) {
|
||||
$queue = SendingTask::create();
|
||||
$queue->hydrate(
|
||||
[
|
||||
@@ -213,7 +213,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
return $queue->save();
|
||||
}
|
||||
|
||||
function _addScheduledTask($type, $status, $scheduled_at = null) {
|
||||
public function _addScheduledTask($type, $status, $scheduled_at = null) {
|
||||
if (!$scheduled_at && $status === ScheduledTask::STATUS_SCHEDULED) {
|
||||
$scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
}
|
||||
@@ -228,7 +228,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
return $task->save();
|
||||
}
|
||||
|
||||
function _enableMigration() {
|
||||
public function _enableMigration() {
|
||||
// Migration can be triggered only if cron execution method is selected
|
||||
// and is not "none"
|
||||
$this->settings->set('cron_trigger', [
|
||||
@@ -236,7 +236,7 @@ class WordPressTest extends \MailPoetTest {
|
||||
]);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . SendingQueue::$_table);
|
||||
|
@@ -9,12 +9,12 @@ use MailPoet\Services\AuthorizedEmailsController;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
|
||||
class AuthorizedSendingEmailsCheckTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
|
||||
function testItRunsCheckOnBridge() {
|
||||
public function testItRunsCheckOnBridge() {
|
||||
$bridge_mock = $this->makeEmpty(AuthorizedEmailsController::class, ['checkAuthorizedEmailAddresses' => Stub\Expected::once()]);
|
||||
$worker = new AuthorizedSendingEmailsCheck($bridge_mock);
|
||||
$worker->processTaskStrategy(ScheduledTask::createOrUpdate([]), microtime(true));
|
||||
|
@@ -10,7 +10,7 @@ use MailPoetVendor\Carbon\Carbon;
|
||||
|
||||
class BeamerTest extends \MailPoetTest {
|
||||
|
||||
function testItSetsLastAnnouncementDate() {
|
||||
public function testItSetsLastAnnouncementDate() {
|
||||
$oldDate = '2019-05-18T10:25:00.000Z';
|
||||
$newDate = '2019-05-22T10:25:00.000Z';
|
||||
$settings = SettingsController::getInstance();
|
||||
@@ -27,7 +27,7 @@ class BeamerTest extends \MailPoetTest {
|
||||
expect($settings->get('last_announcement_date'))->equals(Carbon::createFromTimeString($newDate)->getTimestamp());
|
||||
}
|
||||
|
||||
function testItDoesNothingIfNoResponse() {
|
||||
public function testItDoesNothingIfNoResponse() {
|
||||
$oldDate = '2019-05-18T10:25:00.000Z';
|
||||
$settings = SettingsController::getInstance();
|
||||
$settings->set('last_announcement_date', Carbon::createFromTimeString($oldDate)->getTimestamp());
|
||||
@@ -41,7 +41,7 @@ class BeamerTest extends \MailPoetTest {
|
||||
expect($settings->get('last_announcement_date'))->equals(Carbon::createFromTimeString($oldDate)->getTimestamp());
|
||||
}
|
||||
|
||||
function testItDoesNothingIfWrongResponse() {
|
||||
public function testItDoesNothingIfWrongResponse() {
|
||||
$oldDate = '2019-05-18T10:25:00.000Z';
|
||||
$settings = SettingsController::getInstance();
|
||||
$settings->set('last_announcement_date', Carbon::createFromTimeString($oldDate)->getTimestamp());
|
||||
@@ -55,7 +55,7 @@ class BeamerTest extends \MailPoetTest {
|
||||
expect($settings->get('last_announcement_date'))->equals(Carbon::createFromTimeString($oldDate)->getTimestamp());
|
||||
}
|
||||
|
||||
function testItDoesNothingIfEmptyList() {
|
||||
public function testItDoesNothingIfEmptyList() {
|
||||
$oldDate = '2019-05-18T10:25:00.000Z';
|
||||
$settings = SettingsController::getInstance();
|
||||
$settings->set('last_announcement_date', Carbon::createFromTimeString($oldDate)->getTimestamp());
|
||||
|
@@ -17,7 +17,7 @@ use MailPoetVendor\Idiorm\ORM;
|
||||
require_once('BounceTestMockAPI.php');
|
||||
|
||||
class BounceTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->emails = [
|
||||
'soft_bounce@example.com',
|
||||
@@ -37,24 +37,24 @@ class BounceTest extends \MailPoetTest {
|
||||
$this->worker->api = new MockAPI('key');
|
||||
}
|
||||
|
||||
function testItDefinesConstants() {
|
||||
public function testItDefinesConstants() {
|
||||
expect(Bounce::BATCH_SIZE)->equals(100);
|
||||
}
|
||||
|
||||
function testItCanInitializeBridgeAPI() {
|
||||
public function testItCanInitializeBridgeAPI() {
|
||||
$this->setMailPoetSendingMethod();
|
||||
$worker = new Bounce($this->di_container->get(SettingsController::class), microtime(true));
|
||||
$worker->init();
|
||||
expect($worker->api instanceof API)->true();
|
||||
}
|
||||
|
||||
function testItRequiresMailPoetMethodToBeSetUp() {
|
||||
public function testItRequiresMailPoetMethodToBeSetUp() {
|
||||
expect($this->worker->checkProcessingRequirements())->false();
|
||||
$this->setMailPoetSendingMethod();
|
||||
expect($this->worker->checkProcessingRequirements())->true();
|
||||
}
|
||||
|
||||
function testItDeletesAllSubscribersIfThereAreNoSubscribersToProcessWhenPreparingTask() {
|
||||
public function testItDeletesAllSubscribersIfThereAreNoSubscribersToProcessWhenPreparingTask() {
|
||||
// 1st run - subscribers will be processed
|
||||
$task = $this->createScheduledTask();
|
||||
$this->worker->prepareTaskStrategy($task, microtime(true));
|
||||
@@ -67,7 +67,7 @@ class BounceTest extends \MailPoetTest {
|
||||
expect(ScheduledTaskSubscriber::where('task_id', $task->id)->findMany())->isEmpty();
|
||||
}
|
||||
|
||||
function testItPreparesTask() {
|
||||
public function testItPreparesTask() {
|
||||
$task = $this->createScheduledTask();
|
||||
expect(ScheduledTaskSubscriber::getUnprocessedCount($task->id))->isEmpty();
|
||||
$result = $this->worker->prepareTaskStrategy($task, microtime(true));
|
||||
@@ -75,7 +75,7 @@ class BounceTest extends \MailPoetTest {
|
||||
expect(ScheduledTaskSubscriber::getUnprocessedCount($task->id))->notEmpty();
|
||||
}
|
||||
|
||||
function testItDeletesAllSubscribersIfThereAreNoSubscribersToProcessWhenProcessingTask() {
|
||||
public function testItDeletesAllSubscribersIfThereAreNoSubscribersToProcessWhenProcessingTask() {
|
||||
// prepare subscribers
|
||||
$task = $this->createScheduledTask();
|
||||
$this->worker->prepareTaskStrategy($task, microtime(true));
|
||||
@@ -88,7 +88,7 @@ class BounceTest extends \MailPoetTest {
|
||||
expect(ScheduledTaskSubscriber::where('task_id', $task->id)->findMany())->isEmpty();
|
||||
}
|
||||
|
||||
function testItProcessesTask() {
|
||||
public function testItProcessesTask() {
|
||||
$task = $this->createRunningTask();
|
||||
$this->worker->prepareTaskStrategy($task, microtime(true));
|
||||
expect(ScheduledTaskSubscriber::getUnprocessedCount($task->id))->notEmpty();
|
||||
@@ -96,7 +96,7 @@ class BounceTest extends \MailPoetTest {
|
||||
expect(ScheduledTaskSubscriber::getProcessedCount($task->id))->notEmpty();
|
||||
}
|
||||
|
||||
function testItSetsSubscriberStatusAsBounced() {
|
||||
public function testItSetsSubscriberStatusAsBounced() {
|
||||
$emails = Subscriber::select('email')->findArray();
|
||||
$emails = array_column($emails, 'email');
|
||||
|
||||
@@ -138,7 +138,7 @@ class BounceTest extends \MailPoetTest {
|
||||
return $task;
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTaskSubscriber::$_table);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace MailPoet\Cron\Workers\Bounce;
|
||||
|
||||
class BounceTestMockAPI {
|
||||
function checkBounces(array $emails) {
|
||||
public function checkBounces(array $emails) {
|
||||
return array_map(
|
||||
function ($email) {
|
||||
return [
|
||||
|
@@ -7,7 +7,7 @@ use MailPoet\Models\ScheduledTask;
|
||||
|
||||
class ExportFilesCleanupTest extends \MailPoetTest {
|
||||
|
||||
function testItWorks() {
|
||||
public function testItWorks() {
|
||||
$wp_upload_dir = wp_upload_dir();
|
||||
$old_file_path = $wp_upload_dir['basedir'] . '/mailpoet/MailPoet_export_old_file.csv';
|
||||
$new_file_path = $wp_upload_dir['basedir'] . '/mailpoet/MailPoet_export_new_file.csv';
|
||||
|
@@ -17,7 +17,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
/** @var SettingsController */
|
||||
private $settings;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
$this->settings = SettingsController::getInstance();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
$this->settings->set('tracking.enabled', true);
|
||||
@@ -25,7 +25,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
parent::_before();
|
||||
}
|
||||
|
||||
function testItReactivateInactiveSubscribersWhenIntervalIsSetToNever() {
|
||||
public function testItReactivateInactiveSubscribersWhenIntervalIsSetToNever() {
|
||||
$this->settings->set('deactivate_subscriber_after_inactive_days', 0);
|
||||
$controller_mock = Stub::make(InactiveSubscribersController::class, [
|
||||
'markInactiveSubscribers' => Stub\Expected::never(),
|
||||
@@ -44,7 +44,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
expect($task->scheduled_at)->greaterThan(new Carbon());
|
||||
}
|
||||
|
||||
function testItDoesNotRunWhenTrackingIsDisabled() {
|
||||
public function testItDoesNotRunWhenTrackingIsDisabled() {
|
||||
$this->settings->set('deactivate_subscriber_after_inactive_days', 10);
|
||||
$this->settings->set('tracking.enabled', false);
|
||||
$controller_mock = Stub::make(InactiveSubscribersController::class, [
|
||||
@@ -57,7 +57,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
$worker->processTaskStrategy(ScheduledTask::createOrUpdate([]), microtime(true));
|
||||
}
|
||||
|
||||
function testItSchedulesNextRunWhenFinished() {
|
||||
public function testItSchedulesNextRunWhenFinished() {
|
||||
$this->settings->set('deactivate_subscriber_after_inactive_days', 5);
|
||||
$controller_mock = Stub::make(InactiveSubscribersController::class, [
|
||||
'markInactiveSubscribers' => Stub\Expected::once(1),
|
||||
@@ -76,7 +76,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
expect($task->scheduled_at)->greaterThan(new Carbon());
|
||||
}
|
||||
|
||||
function testRunBatchesUntilItIsFinished() {
|
||||
public function testRunBatchesUntilItIsFinished() {
|
||||
$this->settings->set('deactivate_subscriber_after_inactive_days', 5);
|
||||
$controller_mock = Stub::make(InactiveSubscribersController::class, [
|
||||
'markInactiveSubscribers' => Stub::consecutive(InactiveSubscribers::BATCH_SIZE, InactiveSubscribers::BATCH_SIZE, 1, 'ok'),
|
||||
@@ -93,7 +93,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
expect($controller_mock->markActiveSubscribers(5, 1000))->equals('ok');
|
||||
}
|
||||
|
||||
function testItCanStopDeactivationIfMarkInactiveSubscribersReturnsFalse() {
|
||||
public function testItCanStopDeactivationIfMarkInactiveSubscribersReturnsFalse() {
|
||||
$this->settings->set('deactivate_subscriber_after_inactive_days', 5);
|
||||
$controller_mock = Stub::make(InactiveSubscribersController::class, [
|
||||
'markInactiveSubscribers' => Stub\Expected::once(false),
|
||||
@@ -110,7 +110,7 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
expect(isset($meta['last_subscriber_id']))->equals(false);
|
||||
}
|
||||
|
||||
function testThrowsAnExceptionWhenTimeIsOut() {
|
||||
public function testThrowsAnExceptionWhenTimeIsOut() {
|
||||
$this->settings->set('deactivate_subscriber_after_inactive_days', 5);
|
||||
$controller_mock = Stub::make(InactiveSubscribersController::class, [
|
||||
'markInactiveSubscribers' => Stub\Expected::once(InactiveSubscribers::BATCH_SIZE),
|
||||
|
@@ -5,7 +5,7 @@ namespace MailPoet\Cron\Workers\KeyCheck;
|
||||
class KeyCheckWorkerMockImplementation extends KeyCheckWorker {
|
||||
const TASK_TYPE = 'mock_key_check_worker';
|
||||
|
||||
function checkKey() {
|
||||
public function checkKey() {
|
||||
return ['code' => 12345]; // bogus code
|
||||
}
|
||||
}
|
||||
|
@@ -14,23 +14,23 @@ use MailPoetVendor\Idiorm\ORM;
|
||||
require_once('KeyCheckWorkerMockImplementation.php');
|
||||
|
||||
class KeyCheckWorkerTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->worker = new MockKeyCheckWorker();
|
||||
}
|
||||
|
||||
function testItCanInitializeBridgeAPI() {
|
||||
public function testItCanInitializeBridgeAPI() {
|
||||
$this->worker->init();
|
||||
expect($this->worker->bridge instanceof Bridge)->true();
|
||||
}
|
||||
|
||||
function testItReturnsTrueOnSuccessfulKeyCheck() {
|
||||
public function testItReturnsTrueOnSuccessfulKeyCheck() {
|
||||
$task = $this->createRunningTask();
|
||||
$result = $this->worker->processTaskStrategy($task, microtime(true));
|
||||
expect($result)->true();
|
||||
}
|
||||
|
||||
function testItReschedulesCheckOnException() {
|
||||
public function testItReschedulesCheckOnException() {
|
||||
$worker = Stub::make(
|
||||
$this->worker,
|
||||
[
|
||||
@@ -49,7 +49,7 @@ class KeyCheckWorkerTest extends \MailPoetTest {
|
||||
expect($result)->false();
|
||||
}
|
||||
|
||||
function testItReschedulesCheckOnError() {
|
||||
public function testItReschedulesCheckOnError() {
|
||||
$worker = Stub::make(
|
||||
$this->worker,
|
||||
[
|
||||
@@ -75,7 +75,7 @@ class KeyCheckWorkerTest extends \MailPoetTest {
|
||||
return $task;
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
|
@@ -13,20 +13,20 @@ class PremiumKeyCheckTest extends \MailPoetTest {
|
||||
/** @var SettingsController */
|
||||
private $settings;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->settings = SettingsController::getInstance();
|
||||
$this->premium_key = '123457890abcdef';
|
||||
$this->worker = new PremiumKeyCheck($this->settings, microtime(true));
|
||||
}
|
||||
|
||||
function testItRequiresPremiumKeyToBeSpecified() {
|
||||
public function testItRequiresPremiumKeyToBeSpecified() {
|
||||
expect($this->worker->checkProcessingRequirements())->false();
|
||||
$this->fillPremiumKey();
|
||||
expect($this->worker->checkProcessingRequirements())->true();
|
||||
}
|
||||
|
||||
function testItChecksPremiumKey() {
|
||||
public function testItChecksPremiumKey() {
|
||||
$response = ['code' => Bridge::KEY_VALID];
|
||||
$this->worker->bridge = Stub::make(
|
||||
new Bridge,
|
||||
@@ -56,7 +56,7 @@ class PremiumKeyCheckTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
}
|
||||
}
|
||||
|
@@ -11,19 +11,19 @@ use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Settings\SettingsRepository;
|
||||
|
||||
class SendingServiceKeyCheckTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->mss_key = 'some_key';
|
||||
$this->worker = new SendingServiceKeyCheck($this->di_container->get(SettingsController::class), microtime(true));
|
||||
}
|
||||
|
||||
function testItRequiresMailPoetMethodToBeSetUp() {
|
||||
public function testItRequiresMailPoetMethodToBeSetUp() {
|
||||
expect($this->worker->checkProcessingRequirements())->false();
|
||||
$this->setMailPoetSendingMethod();
|
||||
expect($this->worker->checkProcessingRequirements())->true();
|
||||
}
|
||||
|
||||
function testItChecksMSSKey() {
|
||||
public function testItChecksMSSKey() {
|
||||
$response = ['code' => Bridge::KEY_VALID];
|
||||
$this->worker->bridge = Stub::make(
|
||||
new Bridge,
|
||||
@@ -58,7 +58,7 @@ class SendingServiceKeyCheckTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
}
|
||||
}
|
||||
|
@@ -29,13 +29,13 @@ class SchedulerTest extends \MailPoetTest {
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
$this->cron_helper = ContainerWrapper::getInstance()->get(CronHelper::class);
|
||||
}
|
||||
|
||||
function testItThrowsExceptionWhenExecutionLimitIsReached() {
|
||||
public function testItThrowsExceptionWhenExecutionLimitIsReached() {
|
||||
try {
|
||||
$scheduler = new Scheduler($this->makeEmpty(SubscribersFinder::class), $this->logger_factory, $this->cron_helper);
|
||||
$scheduler->process(microtime(true) - $this->cron_helper->getDaemonExecutionLimit());
|
||||
@@ -45,7 +45,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItCanGetScheduledQueues() {
|
||||
public function testItCanGetScheduledQueues() {
|
||||
expect(Scheduler::getScheduledQueues())->isEmpty();
|
||||
$queue = SendingTask::create();
|
||||
$queue->newsletter_id = 1;
|
||||
@@ -55,7 +55,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(Scheduler::getScheduledQueues())->notEmpty();
|
||||
}
|
||||
|
||||
function testItCanCreateNotificationHistory() {
|
||||
public function testItCanCreateNotificationHistory() {
|
||||
$newsletter = Newsletter::create();
|
||||
$newsletter->type = Newsletter::TYPE_NOTIFICATION;
|
||||
$newsletter->save();
|
||||
@@ -75,7 +75,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($notification_history)->notEmpty();
|
||||
}
|
||||
|
||||
function testItCanDeleteQueueWhenDeliveryIsSetToImmediately() {
|
||||
public function testItCanDeleteQueueWhenDeliveryIsSetToImmediately() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$newsletter_option_field =
|
||||
$this->_createNewsletterOptionField('intervalType', Newsletter::TYPE_WELCOME);
|
||||
@@ -91,7 +91,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findMany())->count(0);
|
||||
}
|
||||
|
||||
function testItCanRescheduleQueueDeliveryTime() {
|
||||
public function testItCanRescheduleQueueDeliveryTime() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$newsletter_option_field =
|
||||
$this->_createNewsletterOptionField('intervalType', Newsletter::TYPE_WELCOME);
|
||||
@@ -114,7 +114,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($queue->scheduled_at)->notNull();
|
||||
}
|
||||
|
||||
function testItFailsWPSubscriberVerificationWhenSubscriberIsNotAWPUser() {
|
||||
public function testItFailsWPSubscriberVerificationWhenSubscriberIsNotAWPUser() {
|
||||
$WP_user = $this->_createOrUpdateWPUser('editor');
|
||||
$subscriber = $this->_createSubscriber();
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_WELCOME);
|
||||
@@ -137,7 +137,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findMany())->count(0);
|
||||
}
|
||||
|
||||
function testItFailsWPSubscriberVerificationWhenSubscriberRoleDoesNotMatch() {
|
||||
public function testItFailsWPSubscriberVerificationWhenSubscriberRoleDoesNotMatch() {
|
||||
$WP_user = $this->_createOrUpdateWPUser('editor');
|
||||
$subscriber = $this->_createSubscriber($WP_user->ID);
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_WELCOME);
|
||||
@@ -161,7 +161,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(count(SendingQueue::findMany()))->equals(0);
|
||||
}
|
||||
|
||||
function testItPassesWPSubscriberVerificationWhenSubscriberExistsAndRoleMatches() {
|
||||
public function testItPassesWPSubscriberVerificationWhenSubscriberExistsAndRoleMatches() {
|
||||
$WP_user = $this->_createOrUpdateWPUser('author');
|
||||
$subscriber = $this->_createSubscriber($WP_user->ID);
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_WELCOME);
|
||||
@@ -182,7 +182,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(count(SendingQueue::findMany()))->greaterOrEquals(1);
|
||||
}
|
||||
|
||||
function testItPassesWPSubscriberVerificationWhenSubscriberHasAnyRole() {
|
||||
public function testItPassesWPSubscriberVerificationWhenSubscriberHasAnyRole() {
|
||||
$WP_user = $this->_createOrUpdateWPUser('author');
|
||||
$subscriber = $this->_createSubscriber($WP_user->ID);
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_WELCOME);
|
||||
@@ -203,7 +203,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(count(SendingQueue::findMany()))->greaterOrEquals(1);
|
||||
}
|
||||
|
||||
function testItDoesNotProcessWelcomeNewsletterWhenThereAreNoSubscribersToProcess() {
|
||||
public function testItDoesNotProcessWelcomeNewsletterWhenThereAreNoSubscribersToProcess() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->setSubscribers([]);
|
||||
@@ -215,7 +215,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findMany())->count(0);
|
||||
}
|
||||
|
||||
function testItDoesNotProcessWelcomeNewsletterWhenWPUserCannotBeVerified() {
|
||||
public function testItDoesNotProcessWelcomeNewsletterWhenWPUserCannotBeVerified() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$newsletter->event = 'user';
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
@@ -230,7 +230,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->false();
|
||||
}
|
||||
|
||||
function testItDoesNotProcessWelcomeNewsletterWhenSubscriberCannotBeVerified() {
|
||||
public function testItDoesNotProcessWelcomeNewsletterWhenSubscriberCannotBeVerified() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$newsletter->event = 'segment';
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
@@ -245,7 +245,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($scheduler->processWelcomeNewsletter($newsletter, $queue))->false();
|
||||
}
|
||||
|
||||
function testItProcessesWelcomeNewsletterWhenSubscriberIsVerified() {
|
||||
public function testItProcessesWelcomeNewsletterWhenSubscriberIsVerified() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$newsletter->event = 'segment';
|
||||
|
||||
@@ -261,7 +261,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($updated_queue->status)->null();
|
||||
}
|
||||
|
||||
function testItProcessesWelcomeNewsletterWhenWPUserIsVerified() {
|
||||
public function testItProcessesWelcomeNewsletterWhenWPUserIsVerified() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$newsletter->event = 'user';
|
||||
|
||||
@@ -278,7 +278,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($updated_queue->status)->null();
|
||||
}
|
||||
|
||||
function testItFailsMailpoetSubscriberVerificationWhenSubscriberDoesNotExist() {
|
||||
public function testItFailsMailpoetSubscriberVerificationWhenSubscriberDoesNotExist() {
|
||||
$scheduler = new Scheduler($this->makeEmpty(SubscribersFinder::class), $this->logger_factory, $this->cron_helper);
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
@@ -290,7 +290,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findMany())->count(0);
|
||||
}
|
||||
|
||||
function testItFailsMailpoetSubscriberVerificationWhenSubscriberIsNotInSegment() {
|
||||
public function testItFailsMailpoetSubscriberVerificationWhenSubscriberIsNotInSegment() {
|
||||
$subscriber = $this->_createSubscriber();
|
||||
$segment = $this->_createSegment();
|
||||
$newsletter = $this->_createNewsletter();
|
||||
@@ -308,7 +308,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findMany())->count(0);
|
||||
}
|
||||
|
||||
function testItReschedulesQueueDeliveryWhenMailpoetSubscriberHasNotConfirmedSubscription() {
|
||||
public function testItReschedulesQueueDeliveryWhenMailpoetSubscriberHasNotConfirmedSubscription() {
|
||||
$current_time = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
Carbon::setTestNow($current_time); // mock carbon to return current time
|
||||
$subscriber = $this->_createSubscriber($wp_user_id = null, 'unconfirmed');
|
||||
@@ -337,7 +337,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItDoesntRunQueueDeliveryWhenMailpoetSubscriberHasUnsubscribed() {
|
||||
public function testItDoesntRunQueueDeliveryWhenMailpoetSubscriberHasUnsubscribed() {
|
||||
$current_time = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
Carbon::setTestNow($current_time); // mock carbon to return current time
|
||||
$subscriber = $this->_createSubscriber($wp_user_id = null, 'unsubscribed');
|
||||
@@ -362,7 +362,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findOne($queue->id))->false();
|
||||
}
|
||||
|
||||
function testItCanVerifyMailpoetSubscriber() {
|
||||
public function testItCanVerifyMailpoetSubscriber() {
|
||||
$subscriber = $this->_createSubscriber();
|
||||
$segment = $this->_createSegment();
|
||||
$subscriber_segment = $this->_createSubscriberSegment($subscriber->id, $segment->id);
|
||||
@@ -383,7 +383,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($result)->true();
|
||||
}
|
||||
|
||||
function testItProcessesScheduledStandardNewsletter() {
|
||||
public function testItProcessesScheduledStandardNewsletter() {
|
||||
$subscriber = $this->_createSubscriber();
|
||||
$segment = $this->_createSegment();
|
||||
$subscriber_segment = $this->_createSubscriberSegment($subscriber->id, $segment->id);
|
||||
@@ -413,7 +413,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($updated_newsletter->status)->equals(Newsletter::STATUS_SENDING);
|
||||
}
|
||||
|
||||
function testItFailsToProcessPostNotificationNewsletterWhenSegmentsDontExist() {
|
||||
public function testItFailsToProcessPostNotificationNewsletterWhenSegmentsDontExist() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
|
||||
@@ -428,7 +428,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($scheduler->processPostNotificationNewsletter($newsletter, $queue))->false();
|
||||
}
|
||||
|
||||
function testItFailsToProcessPostNotificationNewsletterWhenSubscribersNotInSegment() {
|
||||
public function testItFailsToProcessPostNotificationNewsletterWhenSubscribersNotInSegment() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$segment = $this->_createSegment();
|
||||
@@ -443,7 +443,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($scheduler->processPostNotificationNewsletter($newsletter, $queue))->false();
|
||||
}
|
||||
|
||||
function testItCanProcessPostNotificationNewsletter() {
|
||||
public function testItCanProcessPostNotificationNewsletter() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$segment = $this->_createSegment();
|
||||
@@ -478,12 +478,12 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($updated_notification_history->status)->equals(Newsletter::STATUS_SENDING);
|
||||
}
|
||||
|
||||
function testItFailsToProcessWhenScheduledQueuesNotFound() {
|
||||
public function testItFailsToProcessWhenScheduledQueuesNotFound() {
|
||||
$scheduler = new Scheduler($this->makeEmpty(SubscribersFinder::class), $this->logger_factory, $this->cron_helper);
|
||||
expect($scheduler->process())->false();
|
||||
}
|
||||
|
||||
function testItDeletesQueueDuringProcessingWhenNewsletterNotFound() {
|
||||
public function testItDeletesQueueDuringProcessingWhenNewsletterNotFound() {
|
||||
$queue = $this->_createQueue(1);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
$queue->save();
|
||||
@@ -492,7 +492,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findMany())->count(0);
|
||||
}
|
||||
|
||||
function testItDeletesQueueDuringProcessingWhenNewsletterIsSoftDeleted() {
|
||||
public function testItDeletesQueueDuringProcessingWhenNewsletterIsSoftDeleted() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$newsletter->deleted_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
$newsletter->save();
|
||||
@@ -504,7 +504,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect(SendingQueue::findMany())->count(0);
|
||||
}
|
||||
|
||||
function testItProcessesWelcomeNewsletters() {
|
||||
public function testItProcessesWelcomeNewsletters() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_WELCOME);
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -517,7 +517,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$scheduler->process();
|
||||
}
|
||||
|
||||
function testItProcessesNotificationNewsletters() {
|
||||
public function testItProcessesNotificationNewsletters() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -530,7 +530,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$scheduler->process();
|
||||
}
|
||||
|
||||
function testItProcessesStandardScheduledNewsletters() {
|
||||
public function testItProcessesStandardScheduledNewsletters() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_STANDARD);
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -543,7 +543,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$scheduler->process();
|
||||
}
|
||||
|
||||
function testItEnforcesExecutionLimitDuringProcessing() {
|
||||
public function testItEnforcesExecutionLimitDuringProcessing() {
|
||||
$newsletter = $this->_createNewsletter();
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -557,7 +557,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$scheduler->process();
|
||||
}
|
||||
|
||||
function testItDoesNotProcessScheduledJobsWhenNewsletterIsNotActive() {
|
||||
public function testItDoesNotProcessScheduledJobsWhenNewsletterIsNotActive() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_STANDARD, Newsletter::STATUS_DRAFT);
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -572,7 +572,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$scheduler->process();
|
||||
}
|
||||
|
||||
function testItProcessesScheduledJobsWhenNewsletterIsActive() {
|
||||
public function testItProcessesScheduledJobsWhenNewsletterIsActive() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_STANDARD, Newsletter::STATUS_ACTIVE);
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -587,7 +587,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$scheduler->process();
|
||||
}
|
||||
|
||||
function testItReSchedulesBounceTask() {
|
||||
public function testItReSchedulesBounceTask() {
|
||||
$task = ScheduledTask::createOrUpdate([
|
||||
'type' => 'bounce',
|
||||
'status' => ScheduledTask::STATUS_SCHEDULED,
|
||||
@@ -603,7 +603,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($refetched_task->scheduled_at)->lessThan(Carbon::createFromTimestamp(current_time('timestamp'))->addHours(42));
|
||||
}
|
||||
|
||||
function testItDoesNotReSchedulesBounceTaskWhenSoon() {
|
||||
public function testItDoesNotReSchedulesBounceTaskWhenSoon() {
|
||||
$task = ScheduledTask::createOrUpdate([
|
||||
'type' => 'bounce',
|
||||
'status' => ScheduledTask::STATUS_SCHEDULED,
|
||||
@@ -619,7 +619,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($refetched_task->scheduled_at)->lessThan(Carbon::createFromTimestamp(current_time('timestamp'))->addHours(1));
|
||||
}
|
||||
|
||||
function testItProcessesScheduledJobsWhenNewsletterIsScheduled() {
|
||||
public function testItProcessesScheduledJobsWhenNewsletterIsScheduled() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_STANDARD, Newsletter::STATUS_SCHEDULED);
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
$queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -634,7 +634,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$scheduler->process();
|
||||
}
|
||||
|
||||
function testItProcessesScheduledAutomaticEmailWhenSendingToUser() {
|
||||
public function testItProcessesScheduledAutomaticEmailWhenSendingToUser() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_AUTOMATIC, Newsletter::STATUS_SCHEDULED);
|
||||
$subscriber = $this->_createSubscriber();
|
||||
$task = SendingTask::create();
|
||||
@@ -657,7 +657,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($task->status)->null();
|
||||
}
|
||||
|
||||
function testItDeletesScheduledAutomaticEmailWhenUserDoesNotExist() {
|
||||
public function testItDeletesScheduledAutomaticEmailWhenUserDoesNotExist() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_AUTOMATIC, Newsletter::STATUS_SCHEDULED);
|
||||
$subscriber = $this->_createSubscriber();
|
||||
$task = SendingTask::create();
|
||||
@@ -681,7 +681,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($task)->false();
|
||||
}
|
||||
|
||||
function testItProcessesScheduledAutomaticEmailWhenSendingToSegment() {
|
||||
public function testItProcessesScheduledAutomaticEmailWhenSendingToSegment() {
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_AUTOMATIC, Newsletter::STATUS_SCHEDULED);
|
||||
$segment = $this->_createSegment();
|
||||
$subscriber = $this->_createSubscriber();
|
||||
@@ -713,7 +713,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($subscribers[0]->id)->equals($subscriber->id);
|
||||
}
|
||||
|
||||
function testItUpdatesUpdateTime() {
|
||||
public function testItUpdatesUpdateTime() {
|
||||
$originalUpdated = Carbon::createFromTimestamp(current_time('timestamp'))->subHours(5)->toDateTimeString();
|
||||
$newsletter = $this->_createNewsletter(Newsletter::TYPE_WELCOME, Newsletter::STATUS_DRAFT);
|
||||
$queue = $this->_createQueue($newsletter->id);
|
||||
@@ -727,7 +727,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
expect($newQueue->updated_at)->notEquals($originalUpdated);
|
||||
}
|
||||
|
||||
function _createNewsletterSegment($newsletter_id, $segment_id) {
|
||||
public function _createNewsletterSegment($newsletter_id, $segment_id) {
|
||||
$newsletter_segment = NewsletterSegment::create();
|
||||
$newsletter_segment->newsletter_id = $newsletter_id;
|
||||
$newsletter_segment->segment_id = $segment_id;
|
||||
@@ -736,7 +736,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $newsletter_segment;
|
||||
}
|
||||
|
||||
function _createSubscriberSegment($subscriber_id, $segment_id, $status = 'subscribed') {
|
||||
public function _createSubscriberSegment($subscriber_id, $segment_id, $status = 'subscribed') {
|
||||
$subscriber_segment = SubscriberSegment::create();
|
||||
$subscriber_segment->subscriber_id = $subscriber_id;
|
||||
$subscriber_segment->segment_id = $segment_id;
|
||||
@@ -746,7 +746,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $subscriber_segment;
|
||||
}
|
||||
|
||||
function _createSegment() {
|
||||
public function _createSegment() {
|
||||
$segment = Segment::create();
|
||||
$segment->name = 'test';
|
||||
$segment->type = 'default';
|
||||
@@ -755,7 +755,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $segment;
|
||||
}
|
||||
|
||||
function _createSubscriber($wp_user_id = null, $status = 'subscribed') {
|
||||
public function _createSubscriber($wp_user_id = null, $status = 'subscribed') {
|
||||
$subscriber = Subscriber::create();
|
||||
$subscriber->email = 'john@doe.com';
|
||||
$subscriber->first_name = 'John';
|
||||
@@ -767,7 +767,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $subscriber;
|
||||
}
|
||||
|
||||
function _createNewsletter($type = Newsletter::TYPE_NOTIFICATION, $status = 'active') {
|
||||
public function _createNewsletter($type = Newsletter::TYPE_NOTIFICATION, $status = 'active') {
|
||||
$newsletter = Newsletter::create();
|
||||
$newsletter->type = $type;
|
||||
$newsletter->status = $status;
|
||||
@@ -776,7 +776,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $newsletter;
|
||||
}
|
||||
|
||||
function _createNewsletterOptionField($name, $type) {
|
||||
public function _createNewsletterOptionField($name, $type) {
|
||||
$newsletter_option_field = NewsletterOptionField::create();
|
||||
$newsletter_option_field->name = $name;
|
||||
$newsletter_option_field->newsletter_type = $type;
|
||||
@@ -785,7 +785,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $newsletter_option_field;
|
||||
}
|
||||
|
||||
function _createNewsletterOption($option_field_id, $newsletter_id, $value) {
|
||||
public function _createNewsletterOption($option_field_id, $newsletter_id, $value) {
|
||||
$newsletter_option = NewsletterOption::create();
|
||||
$newsletter_option->option_field_id = $option_field_id;
|
||||
$newsletter_option->newsletter_id = $newsletter_id;
|
||||
@@ -795,7 +795,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $newsletter_option;
|
||||
}
|
||||
|
||||
function _createQueue($newsletter_id, $status = SendingQueue::STATUS_SCHEDULED) {
|
||||
public function _createQueue($newsletter_id, $status = SendingQueue::STATUS_SCHEDULED) {
|
||||
$queue = SendingTask::create();
|
||||
$queue->status = $status;
|
||||
$queue->newsletter_id = $newsletter_id;
|
||||
@@ -804,7 +804,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $queue;
|
||||
}
|
||||
|
||||
function _createOrUpdateWPUser($role = null) {
|
||||
public function _createOrUpdateWPUser($role = null) {
|
||||
$email = 'test@example.com';
|
||||
$username = 'phoenix_test_user';
|
||||
if (email_exists($email) === false) {
|
||||
@@ -827,7 +827,7 @@ class SchedulerTest extends \MailPoetTest {
|
||||
return $user;
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
Carbon::setTestNow();
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
|
@@ -19,7 +19,7 @@ class MigrationTest extends \MailPoetTest {
|
||||
/** @var Migration */
|
||||
private $worker;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
// Alter table to test migration
|
||||
$this->downgradeTable();
|
||||
@@ -44,17 +44,17 @@ class MigrationTest extends \MailPoetTest {
|
||||
$this->worker = new Migration(microtime(true));
|
||||
}
|
||||
|
||||
function testItDefinesConstants() {
|
||||
public function testItDefinesConstants() {
|
||||
expect(Migration::BATCH_SIZE)->equals(20);
|
||||
}
|
||||
|
||||
function testItChecksForACompletedMigrationBeforeRunning() {
|
||||
public function testItChecksForACompletedMigrationBeforeRunning() {
|
||||
expect($this->worker->checkProcessingRequirements())->true();
|
||||
$this->createCompletedTask();
|
||||
expect($this->worker->checkProcessingRequirements())->false();
|
||||
}
|
||||
|
||||
function testItPausesSendingWhenPreparingATask() {
|
||||
public function testItPausesSendingWhenPreparingATask() {
|
||||
$task = $this->createScheduledTask();
|
||||
expect(MailerLog::isSendingPaused())->false();
|
||||
$result = $this->worker->prepareTaskStrategy($task, microtime(true));
|
||||
@@ -62,7 +62,7 @@ class MigrationTest extends \MailPoetTest {
|
||||
expect(MailerLog::isSendingPaused())->true();
|
||||
}
|
||||
|
||||
function testItResumesSendingIfThereIsNothingToMigrate() {
|
||||
public function testItResumesSendingIfThereIsNothingToMigrate() {
|
||||
SendingQueue::deleteMany();
|
||||
$this->worker->pauseSending();
|
||||
expect(MailerLog::isSendingPaused())->true();
|
||||
@@ -71,14 +71,14 @@ class MigrationTest extends \MailPoetTest {
|
||||
expect(MailerLog::isSendingPaused())->false();
|
||||
}
|
||||
|
||||
function testItCompletesTaskIfThereIsNothingToMigrate() {
|
||||
public function testItCompletesTaskIfThereIsNothingToMigrate() {
|
||||
SendingQueue::deleteMany();
|
||||
$task = $this->createScheduledTask();
|
||||
$this->worker->prepareTaskStrategy($task, microtime(true));
|
||||
expect(ScheduledTask::findOne($task->id)->status)->equals(ScheduledTask::STATUS_COMPLETED);
|
||||
}
|
||||
|
||||
function testItMigratesSendingQueuesAndSubscribers() {
|
||||
public function testItMigratesSendingQueuesAndSubscribers() {
|
||||
expect($this->worker->getUnmigratedQueues()->count())->equals(4);
|
||||
expect(ScheduledTask::where('type', SendingTask::TASK_TYPE)->findMany())->count(0);
|
||||
expect(ScheduledTaskSubscriber::whereGt('task_id', 0)->count())->equals(0);
|
||||
@@ -102,7 +102,7 @@ class MigrationTest extends \MailPoetTest {
|
||||
expect($migrated_subscribers[1]->processed)->equals(ScheduledTaskSubscriber::STATUS_PROCESSED);
|
||||
}
|
||||
|
||||
function testItResumesSendingAfterMigratingSendingQueuesAndSubscribers() {
|
||||
public function testItResumesSendingAfterMigratingSendingQueuesAndSubscribers() {
|
||||
$this->worker->pauseSending();
|
||||
expect(MailerLog::isSendingPaused())->true();
|
||||
$task = $this->createRunningTask();
|
||||
@@ -110,7 +110,7 @@ class MigrationTest extends \MailPoetTest {
|
||||
expect(MailerLog::isSendingPaused())->false();
|
||||
}
|
||||
|
||||
function testItUsesWPTimeToReturnNextRunDate() {
|
||||
public function testItUsesWPTimeToReturnNextRunDate() {
|
||||
$timestamp = 1514801410;
|
||||
|
||||
$wp = Stub::make(new WPFunctions, [
|
||||
@@ -191,7 +191,7 @@ class MigrationTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTaskSubscriber::$_table);
|
||||
|
@@ -14,12 +14,12 @@ class SendingErrorHandlerTest extends \MailPoetTest {
|
||||
/** @var SendingErrorHandler */
|
||||
private $error_handler;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->error_handler = new SendingErrorHandler();
|
||||
}
|
||||
|
||||
function testItShouldProcessSoftErrorCorrectly() {
|
||||
public function testItShouldProcessSoftErrorCorrectly() {
|
||||
$subscribers = [
|
||||
'john@doe.com',
|
||||
'john@rambo.com',
|
||||
|
@@ -54,7 +54,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$wp_users = get_users();
|
||||
wp_set_current_user($wp_users[0]->ID);
|
||||
@@ -131,13 +131,13 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItConstructs() {
|
||||
public function testItConstructs() {
|
||||
expect($this->sending_queue_worker->batch_size)->equals(SendingQueueWorker::BATCH_SIZE);
|
||||
expect($this->sending_queue_worker->mailer_task instanceof MailerTask);
|
||||
expect($this->sending_queue_worker->newsletter_task instanceof NewsletterTask);
|
||||
}
|
||||
|
||||
function testItEnforcesExecutionLimitsBeforeQueueProcessing() {
|
||||
public function testItEnforcesExecutionLimitsBeforeQueueProcessing() {
|
||||
$sending_queue_worker = Stub::make(
|
||||
new SendingQueueWorker(
|
||||
$this->sending_error_handler,
|
||||
@@ -161,7 +161,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItEnforcesExecutionLimitsAfterSendingWhenQueueStatusIsNotSetToComplete() {
|
||||
public function testItEnforcesExecutionLimitsAfterSendingWhenQueueStatusIsNotSetToComplete() {
|
||||
$sending_queue_worker = Stub::make(
|
||||
new SendingQueueWorker($this->sending_error_handler, $this->stats_notifications_worker, $this->logger_factory, Stub::makeEmpty(NewslettersRepository::class), $this->cron_helper),
|
||||
[
|
||||
@@ -194,7 +194,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItDoesNotEnforceExecutionLimitsAfterSendingWhenQueueStatusIsSetToComplete() {
|
||||
public function testItDoesNotEnforceExecutionLimitsAfterSendingWhenQueueStatusIsSetToComplete() {
|
||||
// when sending is done and there are no more subscribers to process, continue
|
||||
// without enforcing execution limits. this allows the newsletter to be marked as sent
|
||||
// in the process() method and after that execution limits will be enforced
|
||||
@@ -232,7 +232,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItEnforcesExecutionLimitsAfterQueueProcessing() {
|
||||
public function testItEnforcesExecutionLimitsAfterQueueProcessing() {
|
||||
$sending_queue_worker = Stub::make(
|
||||
new SendingQueueWorker($this->sending_error_handler, $this->stats_notifications_worker, $this->logger_factory, Stub::makeEmpty(NewslettersRepository::class), $this->cron_helper),
|
||||
[
|
||||
@@ -246,7 +246,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
$sending_queue_worker->process();
|
||||
}
|
||||
|
||||
function testItDeletesQueueWhenNewsletterIsNotFound() {
|
||||
public function testItDeletesQueueWhenNewsletterIsNotFound() {
|
||||
// queue exists
|
||||
$queue = SendingQueue::findOne($this->queue->id);
|
||||
expect($queue)->notEquals(false);
|
||||
@@ -261,7 +261,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($queue)->false(false);
|
||||
}
|
||||
|
||||
function testItPassesExtraParametersToMailerWhenTrackingIsDisabled() {
|
||||
public function testItPassesExtraParametersToMailerWhenTrackingIsDisabled() {
|
||||
$this->settings->set('tracking.enabled', false);
|
||||
$directUnsubscribeURL = $this->getDirectUnsubscribeURL();
|
||||
$sending_queue_worker = new SendingQueueWorker(
|
||||
@@ -291,7 +291,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
$sending_queue_worker->process();
|
||||
}
|
||||
|
||||
function testItPassesExtraParametersToMailerWhenTrackingIsEnabled() {
|
||||
public function testItPassesExtraParametersToMailerWhenTrackingIsEnabled() {
|
||||
$this->settings->set('tracking.enabled', true);
|
||||
$trackedUnsubscribeURL = $this->getTrackedUnsubscribeURL();
|
||||
$sending_queue_worker = new SendingQueueWorker(
|
||||
@@ -321,7 +321,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
$sending_queue_worker->process();
|
||||
}
|
||||
|
||||
function testItCanProcessSubscribersOneByOne() {
|
||||
public function testItCanProcessSubscribersOneByOne() {
|
||||
$sending_queue_worker = new SendingQueueWorker(
|
||||
$this->sending_error_handler,
|
||||
$this->stats_notifications_worker,
|
||||
@@ -368,7 +368,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($statistics)->notEquals(false);
|
||||
}
|
||||
|
||||
function testItCanProcessSubscribersInBulk() {
|
||||
public function testItCanProcessSubscribersInBulk() {
|
||||
$sending_queue_worker = new SendingQueueWorker(
|
||||
$this->sending_error_handler,
|
||||
$this->stats_notifications_worker,
|
||||
@@ -418,7 +418,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($statistics)->notEquals(false);
|
||||
}
|
||||
|
||||
function testItProcessesStandardNewsletters() {
|
||||
public function testItProcessesStandardNewsletters() {
|
||||
$sending_queue_worker = new SendingQueueWorker(
|
||||
$this->sending_error_handler,
|
||||
$this->stats_notifications_worker,
|
||||
@@ -466,7 +466,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($statistics)->notEquals(false);
|
||||
}
|
||||
|
||||
function testItUpdatesUpdateTime() {
|
||||
public function testItUpdatesUpdateTime() {
|
||||
$originalUpdated = Carbon::createFromTimestamp(current_time('timestamp'))->subHours(5)->toDateTimeString();
|
||||
|
||||
$this->queue->scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
@@ -490,7 +490,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($newQueue->updated_at)->notEquals($originalUpdated);
|
||||
}
|
||||
|
||||
function testItCanProcessWelcomeNewsletters() {
|
||||
public function testItCanProcessWelcomeNewsletters() {
|
||||
$this->newsletter->type = Newsletter::TYPE_WELCOME;
|
||||
$this->newsletter_segment->delete();
|
||||
|
||||
@@ -540,7 +540,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($statistics)->notEquals(false);
|
||||
}
|
||||
|
||||
function testItPreventsSendingWelcomeEmailWhenSubscriberIsUnsubscribed() {
|
||||
public function testItPreventsSendingWelcomeEmailWhenSubscriberIsUnsubscribed() {
|
||||
$this->newsletter->type = Newsletter::TYPE_WELCOME;
|
||||
$this->subscriber->status = Subscriber::STATUS_UNSUBSCRIBED;
|
||||
$this->subscriber->save();
|
||||
@@ -572,7 +572,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($updated_queue->count_to_process)->equals(0);
|
||||
}
|
||||
|
||||
function testItRemovesNonexistentSubscribersFromProcessingList() {
|
||||
public function testItRemovesNonexistentSubscribersFromProcessingList() {
|
||||
$queue = $this->queue;
|
||||
$queue->setSubscribers([
|
||||
$this->subscriber->id(),
|
||||
@@ -607,7 +607,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect(count($statistics))->equals(1);
|
||||
}
|
||||
|
||||
function testItUpdatesQueueSubscriberCountWhenNoneOfSubscribersExist() {
|
||||
public function testItUpdatesQueueSubscriberCountWhenNoneOfSubscribersExist() {
|
||||
$queue = $this->queue;
|
||||
$queue->setSubscribers([
|
||||
123,
|
||||
@@ -633,7 +633,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($updated_queue->count_to_process)->equals(0);
|
||||
}
|
||||
|
||||
function testItDoesNotSendToTrashedSubscribers() {
|
||||
public function testItDoesNotSendToTrashedSubscribers() {
|
||||
$sending_queue_worker = $this->sending_queue_worker;
|
||||
$sending_queue_worker->mailer_task = Stub::make(
|
||||
new MailerTask(),
|
||||
@@ -656,7 +656,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect((int)$updated_queue->count_total)->equals(0);
|
||||
}
|
||||
|
||||
function testItDoesNotSendToGloballyUnsubscribedSubscribers() {
|
||||
public function testItDoesNotSendToGloballyUnsubscribedSubscribers() {
|
||||
$sending_queue_worker = $this->sending_queue_worker;
|
||||
$sending_queue_worker->mailer_task = Stub::make(
|
||||
new MailerTask(),
|
||||
@@ -672,7 +672,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect((int)$updated_queue->count_total)->equals(0);
|
||||
}
|
||||
|
||||
function testItDoesNotSendToSubscribersUnsubscribedFromSegments() {
|
||||
public function testItDoesNotSendToSubscribersUnsubscribedFromSegments() {
|
||||
$sending_queue_worker = $this->sending_queue_worker;
|
||||
$sending_queue_worker->mailer_task = Stub::make(
|
||||
new MailerTask(),
|
||||
@@ -688,7 +688,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect((int)$updated_queue->count_total)->equals(0);
|
||||
}
|
||||
|
||||
function testItDoesNotSendToInactiveSubscribers() {
|
||||
public function testItDoesNotSendToInactiveSubscribers() {
|
||||
$sending_queue_worker = $this->sending_queue_worker;
|
||||
$sending_queue_worker->mailer_task = Stub::make(
|
||||
new MailerTask(),
|
||||
@@ -704,7 +704,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect((int)$updated_queue->count_total)->equals(0);
|
||||
}
|
||||
|
||||
function testItPausesSendingWhenProcessedSubscriberListCannotBeUpdated() {
|
||||
public function testItPausesSendingWhenProcessedSubscriberListCannotBeUpdated() {
|
||||
$sending_task = $this->createMock(SendingTask::class);
|
||||
$sending_task
|
||||
->method('updateProcessedSubscribers')
|
||||
@@ -756,7 +756,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItDoesNotUpdateNewsletterHashDuringSending() {
|
||||
public function testItDoesNotUpdateNewsletterHashDuringSending() {
|
||||
$sending_queue_worker = new SendingQueueWorker(
|
||||
$this->sending_error_handler,
|
||||
$this->stats_notifications_worker,
|
||||
@@ -779,7 +779,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
expect($updated_newsletter->hash)->equals($this->newsletter->hash);
|
||||
}
|
||||
|
||||
function testItAllowsSettingCustomBatchSize() {
|
||||
public function testItAllowsSettingCustomBatchSize() {
|
||||
$custom_batch_size_value = 10;
|
||||
$filter = function() use ($custom_batch_size_value) {
|
||||
return $custom_batch_size_value;
|
||||
@@ -797,7 +797,7 @@ class SendingQueueTest extends \MailPoetTest {
|
||||
$wp->removeFilter('mailpoet_cron_worker_sending_queue_batch_size', $filter);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . SubscriberSegment::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
|
@@ -8,7 +8,7 @@ use MailPoet\Models\NewsletterLink;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
|
||||
class LinksTest extends \MailPoetTest {
|
||||
function testItCanSaveLinks() {
|
||||
public function testItCanSaveLinks() {
|
||||
$links = [
|
||||
[
|
||||
'link' => 'http://example.com',
|
||||
@@ -25,7 +25,7 @@ class LinksTest extends \MailPoetTest {
|
||||
expect($newsletter_link->url)->equals($links[0]['link']);
|
||||
}
|
||||
|
||||
function testItCanHashAndReplaceLinks() {
|
||||
public function testItCanHashAndReplaceLinks() {
|
||||
$rendered_newsletter = [
|
||||
'html' => '<a href="http://example.com">Example Link</a>',
|
||||
'text' => '<a href="http://example.com">Example Link</a>',
|
||||
@@ -40,7 +40,7 @@ class LinksTest extends \MailPoetTest {
|
||||
expect($processed_and_hashed_links[0]['link'])->equals('http://example.com');
|
||||
}
|
||||
|
||||
function testItCanProcessRenderedBody() {
|
||||
public function testItCanProcessRenderedBody() {
|
||||
$newsletter = Newsletter::create();
|
||||
$newsletter->type = Newsletter::TYPE_STANDARD;
|
||||
$newsletter->save();
|
||||
@@ -55,7 +55,7 @@ class LinksTest extends \MailPoetTest {
|
||||
expect($result['html'])->contains($newsletter_link->hash);
|
||||
}
|
||||
|
||||
function testItCanEnsureThatUnsubscribeLinkIsAlwaysPresent() {
|
||||
public function testItCanEnsureThatUnsubscribeLinkIsAlwaysPresent() {
|
||||
$newsletter = Newsletter::create();
|
||||
$newsletter->type = Newsletter::TYPE_STANDARD;
|
||||
$newsletter->save();
|
||||
@@ -70,7 +70,7 @@ class LinksTest extends \MailPoetTest {
|
||||
expect($unsubscribe_count)->equals(1);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . NewsletterLink::$_table);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class MailerTest extends \MailPoetTest {
|
||||
/** @var SettingsController */
|
||||
private $settings;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$wp_users = get_users();
|
||||
wp_set_current_user($wp_users[0]->ID);
|
||||
@@ -36,11 +36,11 @@ class MailerTest extends \MailPoetTest {
|
||||
$this->sender = $this->settings->get('sender');
|
||||
}
|
||||
|
||||
function testConfiguresMailerWhenItConstructs() {
|
||||
public function testConfiguresMailerWhenItConstructs() {
|
||||
expect($this->mailer_task->mailer instanceof \MailPoet\Mailer\Mailer)->true();
|
||||
}
|
||||
|
||||
function testItCanConfigureMailerWithSenderAndReplyToAddresses() {
|
||||
public function testItCanConfigureMailerWithSenderAndReplyToAddresses() {
|
||||
$newsletter = new \stdClass();
|
||||
|
||||
// when no sender/reply-to information is set, use the sender information
|
||||
@@ -64,19 +64,19 @@ class MailerTest extends \MailPoetTest {
|
||||
expect($mailer->reply_to['reply_to_email'])->equals($newsletter->reply_to_address);
|
||||
}
|
||||
|
||||
function testItGetsMailerLog() {
|
||||
public function testItGetsMailerLog() {
|
||||
$mailer_log = $this->mailer_task->getMailerLog();
|
||||
expect(is_array($mailer_log))->true();
|
||||
}
|
||||
|
||||
function testItUpdatesMailerLogSentCount() {
|
||||
public function testItUpdatesMailerLogSentCount() {
|
||||
$mailer_log = $this->mailer_task->getMailerLog();
|
||||
expect($mailer_log['sent'])->equals(0);
|
||||
$mailer_log = $this->mailer_task->updateSentCount();
|
||||
expect($mailer_log['sent'])->equals(1);
|
||||
}
|
||||
|
||||
function testItGetsProcessingMethod() {
|
||||
public function testItGetsProcessingMethod() {
|
||||
// when using MailPoet method, newsletters should be processed in bulk
|
||||
$this->settings->set(
|
||||
Mailer::MAILER_CONFIG_SETTING_NAME,
|
||||
@@ -99,7 +99,7 @@ class MailerTest extends \MailPoetTest {
|
||||
expect($mailer_task->getProcessingMethod())->equals('individual');
|
||||
}
|
||||
|
||||
function testItCanPrepareSubscriberForSending() {
|
||||
public function testItCanPrepareSubscriberForSending() {
|
||||
$subscriber = Subscriber::create();
|
||||
$subscriber->email = 'test@example.com';
|
||||
$subscriber->first_name = 'John';
|
||||
@@ -109,7 +109,7 @@ class MailerTest extends \MailPoetTest {
|
||||
expect($prepared_subscriber)->equals('John Doe <test@example.com>');
|
||||
}
|
||||
|
||||
function testItCanSend() {
|
||||
public function testItCanSend() {
|
||||
$php_mail_class = 'MailPoet\Mailer\Methods\PHPMail';
|
||||
$this->settings->set(
|
||||
Mailer::MAILER_CONFIG_SETTING_NAME,
|
||||
@@ -139,7 +139,7 @@ class MailerTest extends \MailPoetTest {
|
||||
expect($mailer_task->send('Newsletter', 'Subscriber'))->true();
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->newsletter_task = new NewsletterTask();
|
||||
$this->subscriber = Subscriber::create();
|
||||
@@ -71,11 +71,11 @@ class NewsletterTest extends \MailPoetTest {
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
}
|
||||
|
||||
function testItConstructs() {
|
||||
public function testItConstructs() {
|
||||
expect($this->newsletter_task->tracking_enabled)->true();
|
||||
}
|
||||
|
||||
function testItDoesNotGetNewsletterWhenStatusIsNotActiveOrSending() {
|
||||
public function testItDoesNotGetNewsletterWhenStatusIsNotActiveOrSending() {
|
||||
// draft or any other status return false
|
||||
$newsletter = $this->newsletter;
|
||||
$newsletter->status = Newsletter::STATUS_DRAFT;
|
||||
@@ -94,14 +94,14 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($this->newsletter_task->getNewsletterFromQueue($this->queue))->isInstanceOf('Mailpoet\Models\Newsletter');
|
||||
}
|
||||
|
||||
function testItDoesNotGetDeletedNewsletter() {
|
||||
public function testItDoesNotGetDeletedNewsletter() {
|
||||
$newsletter = $this->newsletter;
|
||||
$newsletter->set_expr('deleted_at', 'NOW()');
|
||||
$newsletter->save();
|
||||
expect($this->newsletter_task->getNewsletterFromQueue($this->queue))->false();
|
||||
}
|
||||
|
||||
function testItDoesNotGetNewsletterWhenParentNewsletterStatusIsNotActiveOrSending() {
|
||||
public function testItDoesNotGetNewsletterWhenParentNewsletterStatusIsNotActiveOrSending() {
|
||||
// draft or any other status return false
|
||||
$parent_newsletter = $this->parent_newsletter;
|
||||
$parent_newsletter->status = Newsletter::STATUS_DRAFT;
|
||||
@@ -132,7 +132,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($this->newsletter_task->getNewsletterFromQueue($this->queue))->isInstanceOf('Mailpoet\Models\Newsletter');
|
||||
}
|
||||
|
||||
function testItDoesNotGetDeletedNewsletterWhenParentNewsletterIsDeleted() {
|
||||
public function testItDoesNotGetDeletedNewsletterWhenParentNewsletterIsDeleted() {
|
||||
$parent_newsletter = $this->parent_newsletter;
|
||||
$parent_newsletter->set_expr('deleted_at', 'NOW()');
|
||||
$parent_newsletter->save();
|
||||
@@ -143,14 +143,14 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($this->newsletter_task->getNewsletterFromQueue($this->queue))->false();
|
||||
}
|
||||
|
||||
function testItReturnsNewsletterObjectWhenRenderedNewsletterBodyExistsInTheQueue() {
|
||||
public function testItReturnsNewsletterObjectWhenRenderedNewsletterBodyExistsInTheQueue() {
|
||||
$queue = $this->queue;
|
||||
$queue->newsletter_rendered_body = ['html' => 'test', 'text' => 'test'];
|
||||
$result = $this->newsletter_task->preProcessNewsletter($this->newsletter, $queue);
|
||||
expect($result instanceof \MailPoet\Models\Newsletter)->true();
|
||||
}
|
||||
|
||||
function testItHashesLinksAndInsertsTrackingImageWhenTrackingIsEnabled() {
|
||||
public function testItHashesLinksAndInsertsTrackingImageWhenTrackingIsEnabled() {
|
||||
$wp = Stub::make(new WPFunctions, [
|
||||
'applyFilters' => asCallable([WPHooksHelper::class, 'applyFilters']),
|
||||
]);
|
||||
@@ -172,7 +172,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect(WPHooksHelper::getFilterApplied($hook_name)[1] instanceof Newsletter)->true();
|
||||
}
|
||||
|
||||
function testItDoesNotHashLinksAndInsertTrackingCodeWhenTrackingIsDisabled() {
|
||||
public function testItDoesNotHashLinksAndInsertTrackingCodeWhenTrackingIsDisabled() {
|
||||
$wp = Stub::make(new WPFunctions, [
|
||||
'applyFilters' => asCallable([WPHooksHelper::class, 'applyFilters']),
|
||||
]);
|
||||
@@ -195,7 +195,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect(WPHooksHelper::getFilterApplied($hook_name)[1] instanceof Newsletter)->true();
|
||||
}
|
||||
|
||||
function testItReturnsFalseAndDeletesNewsletterWhenPostNotificationContainsNoPosts() {
|
||||
public function testItReturnsFalseAndDeletesNewsletterWhenPostNotificationContainsNoPosts() {
|
||||
$newsletter = $this->newsletter;
|
||||
|
||||
$newsletter->type = Newsletter::TYPE_NOTIFICATION_HISTORY;
|
||||
@@ -211,7 +211,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($newsletter)->false();
|
||||
}
|
||||
|
||||
function testItSavesNewsletterPosts() {
|
||||
public function testItSavesNewsletterPosts() {
|
||||
$this->newsletter->type = Newsletter::TYPE_NOTIFICATION_HISTORY;
|
||||
$this->newsletter->parent_id = $this->newsletter->id;
|
||||
$posts_task = $this->make(PostsTask::class, [
|
||||
@@ -226,7 +226,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($newsletter_post->post_id)->equals('10');
|
||||
}
|
||||
|
||||
function testItUpdatesStatusAndSetsSentAtDateOnlyForStandardAndPostNotificationNewsletters() {
|
||||
public function testItUpdatesStatusAndSetsSentAtDateOnlyForStandardAndPostNotificationNewsletters() {
|
||||
$newsletter = $this->newsletter;
|
||||
$queue = new \stdClass();
|
||||
$queue->processed_at = date('Y-m-d H:i:s');
|
||||
@@ -258,7 +258,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($updated_newsletter->status)->notEquals(Newsletter::STATUS_SENT);
|
||||
}
|
||||
|
||||
function testItDoesNotRenderSubscriberShortcodeInSubjectWhenPreprocessingNewsletter() {
|
||||
public function testItDoesNotRenderSubscriberShortcodeInSubjectWhenPreprocessingNewsletter() {
|
||||
$newsletter = $this->newsletter;
|
||||
$newsletter->subject = 'Newsletter for [subscriber:firstname] [date:dordinal]';
|
||||
$queue = $this->queue;
|
||||
@@ -269,7 +269,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
->contains(date_i18n('jS', $wp->currentTime('timestamp')));
|
||||
}
|
||||
|
||||
function testItUsesADefaultSubjectIfRenderedSubjectIsEmptyWhenPreprocessingNewsletter() {
|
||||
public function testItUsesADefaultSubjectIfRenderedSubjectIsEmptyWhenPreprocessingNewsletter() {
|
||||
$newsletter = $this->newsletter;
|
||||
$newsletter->subject = ' [custom_shortcode:should_render_empty] ';
|
||||
$queue = $this->queue;
|
||||
@@ -279,7 +279,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
->equals('No subject');
|
||||
}
|
||||
|
||||
function testItUsesRenderedNewsletterBodyAndSubjectFromQueueObjectWhenPreparingNewsletterForSending() {
|
||||
public function testItUsesRenderedNewsletterBodyAndSubjectFromQueueObjectWhenPreparingNewsletterForSending() {
|
||||
$queue = $this->queue;
|
||||
$queue->newsletter_rendered_body = [
|
||||
'html' => 'queue HTML body',
|
||||
@@ -304,7 +304,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($result['body']['text'])->equals('queue TEXT body');
|
||||
}
|
||||
|
||||
function testItRendersShortcodesAndReplacesSubscriberDataInLinks() {
|
||||
public function testItRendersShortcodesAndReplacesSubscriberDataInLinks() {
|
||||
$newsletter = $this->newsletter_task->preProcessNewsletter($this->newsletter, $this->queue);
|
||||
$result = $this->newsletter_task->prepareNewsletterForSending(
|
||||
$newsletter,
|
||||
@@ -318,7 +318,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
->contains(Router::NAME . '&endpoint=track&action=click&data=');
|
||||
}
|
||||
|
||||
function testItDoesNotReplaceSubscriberDataInLinksWhenTrackingIsNotEnabled() {
|
||||
public function testItDoesNotReplaceSubscriberDataInLinksWhenTrackingIsNotEnabled() {
|
||||
$newsletter_task = $this->newsletter_task;
|
||||
$newsletter_task->tracking_enabled = false;
|
||||
$newsletter = $newsletter_task->preProcessNewsletter($this->newsletter, $this->queue);
|
||||
@@ -333,7 +333,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
->notContains(Router::NAME . '&endpoint=track&action=click&data=');
|
||||
}
|
||||
|
||||
function testItGetsSegments() {
|
||||
public function testItGetsSegments() {
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
$newsletter_segment = NewsletterSegment::create();
|
||||
$newsletter_segment->newsletter_id = $this->newsletter->id;
|
||||
@@ -345,7 +345,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItLogsErrorWhenQueueWithCannotBeSaved() {
|
||||
public function testItLogsErrorWhenQueueWithCannotBeSaved() {
|
||||
$queue = $this->queue;
|
||||
$queue->non_existent_column = true; // this will trigger save error
|
||||
try {
|
||||
@@ -358,7 +358,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItLogsErrorWhenExistingRenderedNewsletterBodyIsInvalid() {
|
||||
public function testItLogsErrorWhenExistingRenderedNewsletterBodyIsInvalid() {
|
||||
$queue_mock = $this->createMock(SendingTask::class);
|
||||
$queue_mock
|
||||
->expects($this->any())
|
||||
@@ -379,7 +379,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItLogsErrorWhenNewlyRenderedNewsletterBodyIsInvalid() {
|
||||
public function testItLogsErrorWhenNewlyRenderedNewsletterBodyIsInvalid() {
|
||||
$queue = $this->queue;
|
||||
$queue_mock = $this->createMock(SendingTask::class);
|
||||
$queue_mock
|
||||
@@ -410,7 +410,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItPreProcessesNewsletterWhenNewlyRenderedNewsletterBodyIsValid() {
|
||||
public function testItPreProcessesNewsletterWhenNewlyRenderedNewsletterBodyIsValid() {
|
||||
$queue = $this->queue;
|
||||
$queue_mock = $this->createMock(SendingTask::class);
|
||||
$queue_mock
|
||||
@@ -444,7 +444,7 @@ class NewsletterTest extends \MailPoetTest {
|
||||
expect($newsletter_task->preProcessNewsletter($this->newsletter, $queue_mock))->equals($this->newsletter);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
|
@@ -12,12 +12,12 @@ class PostsTest extends \MailPoetTest {
|
||||
/** @var PostsTask */
|
||||
private $posts_task;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->posts_task = new PostsTask;
|
||||
}
|
||||
|
||||
function testItFailsWhenNoPostsArePresent() {
|
||||
public function testItFailsWhenNoPostsArePresent() {
|
||||
$newsletter = (object)[
|
||||
'id' => 1,
|
||||
'type' => Newsletter::TYPE_NOTIFICATION_HISTORY,
|
||||
@@ -28,7 +28,7 @@ class PostsTest extends \MailPoetTest {
|
||||
expect($this->posts_task->extractAndSave($rendered_newsletter, $newsletter))->equals(false);
|
||||
}
|
||||
|
||||
function testItCanExtractAndSavePosts() {
|
||||
public function testItCanExtractAndSavePosts() {
|
||||
$post_id = 10;
|
||||
$newsletter = (object)[
|
||||
'id' => 2,
|
||||
@@ -44,7 +44,7 @@ class PostsTest extends \MailPoetTest {
|
||||
expect($newsletter_post->post_id)->equals($post_id);
|
||||
}
|
||||
|
||||
function testItDoesNotSavePostsWhenNewsletterIsNotANotificationHistory() {
|
||||
public function testItDoesNotSavePostsWhenNewsletterIsNotANotificationHistory() {
|
||||
$post_id = 10;
|
||||
$newsletter = (object)[
|
||||
'id' => 2,
|
||||
@@ -59,7 +59,7 @@ class PostsTest extends \MailPoetTest {
|
||||
expect($this->posts_task->extractAndSave($rendered_newsletter, $newsletter))->equals(false);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . NewsletterPost::$_table);
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ use MailPoet\Models\Subscriber;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
|
||||
class ShortcodesTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->WP_post = wp_insert_post(
|
||||
[
|
||||
@@ -20,7 +20,7 @@ class ShortcodesTest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testItCanReplaceShortcodes() {
|
||||
public function testItCanReplaceShortcodes() {
|
||||
$queue = $newsletter = (object)[
|
||||
'id' => 1,
|
||||
];
|
||||
@@ -35,7 +35,7 @@ class ShortcodesTest extends \MailPoetTest {
|
||||
expect($result)->equals('John Doe');
|
||||
}
|
||||
|
||||
function testItCanReplaceShortcodesInOneStringUsingContentsFromAnother() {
|
||||
public function testItCanReplaceShortcodesInOneStringUsingContentsFromAnother() {
|
||||
$wp_post = get_post($this->WP_post);
|
||||
$content = 'Subject line with one shortcode: [newsletter:post_title]';
|
||||
$content_source = '<a data-post-id="' . $this->WP_post . '" href="#">latest post</a>';
|
||||
@@ -48,7 +48,7 @@ class ShortcodesTest extends \MailPoetTest {
|
||||
expect(Shortcodes::process($content, $content_source))->equals('Subject line with one shortcode: ' . $wp_post->post_title);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . SendingQueue::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
wp_delete_post($this->WP_post, true);
|
||||
|
@@ -6,7 +6,7 @@ class SimpleWorkerMockImplementation extends SimpleWorker {
|
||||
const TASK_TYPE = 'mock_simple_worker';
|
||||
const SUPPORT_MULTIPLE_INSTANCES = false;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
// to be mocked
|
||||
}
|
||||
}
|
||||
|
@@ -14,13 +14,13 @@ use MailPoetVendor\Idiorm\ORM;
|
||||
require_once __DIR__ . '/SimpleWorkerMockImplementation.php';
|
||||
|
||||
class SimpleWorkerTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->cron_helper = ContainerWrapper::getInstance()->get(CronHelper::class);
|
||||
$this->worker = new MockSimpleWorker();
|
||||
}
|
||||
|
||||
function testItRequiresTaskTypeToConstruct() {
|
||||
public function testItRequiresTaskTypeToConstruct() {
|
||||
$worker = Stub::make(
|
||||
'MailPoet\Cron\Workers\SimpleWorker',
|
||||
[],
|
||||
@@ -35,13 +35,13 @@ class SimpleWorkerTest extends \MailPoetTest {
|
||||
}
|
||||
}
|
||||
|
||||
function testItSchedulesTask() {
|
||||
public function testItSchedulesTask() {
|
||||
expect(ScheduledTask::where('type', MockSimpleWorker::TASK_TYPE)->findMany())->isEmpty();
|
||||
(new MockSimpleWorker())->schedule();
|
||||
expect(ScheduledTask::where('type', MockSimpleWorker::TASK_TYPE)->findMany())->notEmpty();
|
||||
}
|
||||
|
||||
function testItDoesNotScheduleTaskTwice() {
|
||||
public function testItDoesNotScheduleTaskTwice() {
|
||||
$worker = new MockSimpleWorker();
|
||||
expect(count(ScheduledTask::where('type', MockSimpleWorker::TASK_TYPE)->findMany()))->equals(0);
|
||||
$worker->schedule();
|
||||
@@ -50,7 +50,7 @@ class SimpleWorkerTest extends \MailPoetTest {
|
||||
expect(count(ScheduledTask::where('type', MockSimpleWorker::TASK_TYPE)->findMany()))->equals(1);
|
||||
}
|
||||
|
||||
function testItCalculatesNextRunDateWithinNextWeekBoundaries() {
|
||||
public function testItCalculatesNextRunDateWithinNextWeekBoundaries() {
|
||||
$current_date = Carbon::createFromTimestamp(current_time('timestamp'));
|
||||
$next_run_date = (new MockSimpleWorker())->getNextRunDate();
|
||||
$difference = $next_run_date->diffInDays($current_date);
|
||||
@@ -60,7 +60,7 @@ class SimpleWorkerTest extends \MailPoetTest {
|
||||
expect($difference)->greaterOrEquals(0);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->di_container->get(SettingsRepository::class)->truncate();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
/** @var CronWorkerRunner */
|
||||
private $cron_worker_runner;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
@@ -68,7 +68,7 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
$this->settings->set('tracking.enabled', true);
|
||||
}
|
||||
|
||||
function testItDoesntWorkIfDisabled() {
|
||||
public function testItDoesntWorkIfDisabled() {
|
||||
$this->settings->set(Worker::SETTINGS_KEY, [
|
||||
'automated' => false,
|
||||
'address' => 'email@example.com',
|
||||
@@ -76,7 +76,7 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
expect($this->stats_notifications->checkProcessingRequirements())->equals(false);
|
||||
}
|
||||
|
||||
function testItDoesntWorkIfNoEmail() {
|
||||
public function testItDoesntWorkIfNoEmail() {
|
||||
$this->settings->set(Worker::SETTINGS_KEY, [
|
||||
'automated' => true,
|
||||
'address' => '',
|
||||
@@ -84,16 +84,16 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
expect($this->stats_notifications->checkProcessingRequirements())->equals(false);
|
||||
}
|
||||
|
||||
function testItDoesntWorkIfTrackingIsDisabled() {
|
||||
public function testItDoesntWorkIfTrackingIsDisabled() {
|
||||
$this->settings->set('tracking.enabled', false);
|
||||
expect($this->stats_notifications->checkProcessingRequirements())->equals(false);
|
||||
}
|
||||
|
||||
function testItDoesWorkIfEnabled() {
|
||||
public function testItDoesWorkIfEnabled() {
|
||||
expect($this->stats_notifications->checkProcessingRequirements())->equals(true);
|
||||
}
|
||||
|
||||
function testItDoesntRenderIfNoNewslettersFound() {
|
||||
public function testItDoesntRenderIfNoNewslettersFound() {
|
||||
$this->renderer->expects($this->never())
|
||||
->method('render');
|
||||
$this->mailer->expects($this->never())
|
||||
@@ -104,7 +104,7 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
expect($result)->equals(true);
|
||||
}
|
||||
|
||||
function testItRenders() {
|
||||
public function testItRenders() {
|
||||
Newsletter::createOrUpdate([
|
||||
'id' => 8763,
|
||||
'subject' => 'Subject',
|
||||
@@ -132,7 +132,7 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
expect($result)->equals(true);
|
||||
}
|
||||
|
||||
function testItSends() {
|
||||
public function testItSends() {
|
||||
Newsletter::createOrUpdate([
|
||||
'id' => 8763,
|
||||
'subject' => 'Subject',
|
||||
@@ -162,7 +162,7 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
expect($result)->equals(true);
|
||||
}
|
||||
|
||||
function testItPreparesContext() {
|
||||
public function testItPreparesContext() {
|
||||
Newsletter::createOrUpdate([
|
||||
'id' => 8764,
|
||||
'subject' => 'Subject',
|
||||
@@ -183,7 +183,7 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
$this->cron_worker_runner->run($this->stats_notifications);
|
||||
}
|
||||
|
||||
function testItAddsNewsletterStatsToContext() {
|
||||
public function testItAddsNewsletterStatsToContext() {
|
||||
Newsletter::createOrUpdate([
|
||||
'id' => 8765,
|
||||
'subject' => 'Subject',
|
||||
|
@@ -51,7 +51,7 @@ class WorkerTest extends \MailPoetTest {
|
||||
/** @var NewsletterLinkRepository */
|
||||
private $newsletter_link_repository;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . StatisticsClicks::$_table);
|
||||
@@ -164,7 +164,7 @@ class WorkerTest extends \MailPoetTest {
|
||||
]);
|
||||
}
|
||||
|
||||
function testRendersTemplate() {
|
||||
public function testRendersTemplate() {
|
||||
$this->renderer->expects($this->exactly(2))
|
||||
->method('render');
|
||||
$this->renderer->expects($this->at(0))
|
||||
@@ -178,7 +178,7 @@ class WorkerTest extends \MailPoetTest {
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testAddsSubjectToContext() {
|
||||
public function testAddsSubjectToContext() {
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
@@ -190,7 +190,7 @@ class WorkerTest extends \MailPoetTest {
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testAddsPreHeaderToContext() {
|
||||
public function testAddsPreHeaderToContext() {
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
@@ -202,7 +202,7 @@ class WorkerTest extends \MailPoetTest {
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testAddsWPUrlsToContext() {
|
||||
public function testAddsWPUrlsToContext() {
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
@@ -215,7 +215,7 @@ class WorkerTest extends \MailPoetTest {
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testAddsLinksToContext() {
|
||||
public function testAddsLinksToContext() {
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
@@ -228,7 +228,7 @@ class WorkerTest extends \MailPoetTest {
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testReplacesShortcodeLinks() {
|
||||
public function testReplacesShortcodeLinks() {
|
||||
$link = NewsletterLink::createOrUpdate([
|
||||
'url' => '[link:subscription_manage_url]',
|
||||
'newsletter_id' => $this->newsletter->id(),
|
||||
@@ -270,14 +270,14 @@ class WorkerTest extends \MailPoetTest {
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testSends() {
|
||||
public function testSends() {
|
||||
$this->mailer->expects($this->once())
|
||||
->method('send');
|
||||
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testItWorksForNewsletterWithNoStats() {
|
||||
public function testItWorksForNewsletterWithNoStats() {
|
||||
$newsletter = Newsletter::createOrUpdate([
|
||||
'subject' => 'Email Subject2',
|
||||
'type' => Newsletter::TYPE_STANDARD,
|
||||
|
@@ -17,7 +17,7 @@ class UnsubscribeTokensTest extends \MailPoetTest {
|
||||
private $subscriber_without_token;
|
||||
private $newsletter_without_token;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
@@ -47,7 +47,7 @@ class UnsubscribeTokensTest extends \MailPoetTest {
|
||||
$this->newsletter_without_token->save();
|
||||
}
|
||||
|
||||
function testItAddsTokensToSubscribers() {
|
||||
public function testItAddsTokensToSubscribers() {
|
||||
$worker = new UnsubscribeTokens();
|
||||
$worker->processTaskStrategy(ScheduledTask::createOrUpdate(), microtime(true));
|
||||
$this->subscriber_with_token = Subscriber::findOne($this->subscriber_with_token->id);
|
||||
@@ -56,7 +56,7 @@ class UnsubscribeTokensTest extends \MailPoetTest {
|
||||
expect(strlen($this->subscriber_without_token->unsubscribe_token))->equals(15);
|
||||
}
|
||||
|
||||
function testItAddsTokensToNewsletters() {
|
||||
public function testItAddsTokensToNewsletters() {
|
||||
$worker = new UnsubscribeTokens();
|
||||
$worker->processTaskStrategy(ScheduledTask::createOrUpdate(), microtime(true));
|
||||
$this->newsletter_with_token = Newsletter::findOne($this->newsletter_with_token->id);
|
||||
@@ -65,7 +65,7 @@ class UnsubscribeTokensTest extends \MailPoetTest {
|
||||
expect(strlen($this->newsletter_without_token->unsubscribe_token))->equals(15);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||
ORM::raw_execute('TRUNCATE ' . Newsletter::$_table);
|
||||
|
@@ -26,7 +26,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
/** @var CronWorkerRunner */
|
||||
private $cron_worker_runner;
|
||||
|
||||
function _before() {
|
||||
public function _before() {
|
||||
$this->cleanup();
|
||||
$this->woocommerce_helper = $this->createMock(WooCommerceHelper::class);
|
||||
$this->woocommerce_purchases = $this->createMock(WooCommercePurchases::class);
|
||||
@@ -37,7 +37,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
]);
|
||||
}
|
||||
|
||||
function testItDoesNotRunIfWooCommerceIsDisabled() {
|
||||
public function testItDoesNotRunIfWooCommerceIsDisabled() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')->willReturn(false);
|
||||
expect($this->worker->checkProcessingRequirements())->false();
|
||||
|
||||
@@ -46,7 +46,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
expect($tasks)->isEmpty();
|
||||
}
|
||||
|
||||
function testItRunsIfWooCommerceIsEnabled() {
|
||||
public function testItRunsIfWooCommerceIsEnabled() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')->willReturn(true);
|
||||
expect($this->worker->checkProcessingRequirements())->true();
|
||||
|
||||
@@ -55,7 +55,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
expect($tasks)->count(1);
|
||||
}
|
||||
|
||||
function testItRunsOnlyOnce() {
|
||||
public function testItRunsOnlyOnce() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')->willReturn(true);
|
||||
$this->woocommerce_helper->method('wcGetOrders')->willReturn([]);
|
||||
|
||||
@@ -87,7 +87,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
expect($tasks)->count(1);
|
||||
}
|
||||
|
||||
function testItTracksOrders() {
|
||||
public function testItTracksOrders() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')->willReturn(true);
|
||||
$this->woocommerce_helper->method('wcGetOrders')->willReturn([1, 2, 3]);
|
||||
$this->createClick();
|
||||
@@ -104,7 +104,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
|
||||
function testItContinuesFromLastId() {
|
||||
public function testItContinuesFromLastId() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')->willReturn(true);
|
||||
$this->woocommerce_helper->method('wcGetOrders')->willReturnOnConsecutiveCalls([1, 2, 3], [4, 5], []);
|
||||
$this->createClick();
|
||||
@@ -130,7 +130,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
expect($tasks[0]->status)->equals(ScheduledTask::STATUS_COMPLETED);
|
||||
}
|
||||
|
||||
function testItResetsPreviouslyTrackedOrders() {
|
||||
public function testItResetsPreviouslyTrackedOrders() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')->willReturn(true);
|
||||
$this->woocommerce_helper->method('wcGetOrders')->willReturnOnConsecutiveCalls([1, 2], [3], [4]);
|
||||
$click = $this->createClick();
|
||||
@@ -159,7 +159,7 @@ class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
expect(StatisticsWooCommercePurchases::findMany())->count(0);
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
$this->cleanup();
|
||||
}
|
||||
|
||||
|
@@ -10,25 +10,25 @@ use MailPoetVendor\Carbon\Carbon;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
|
||||
class WooCommerceSyncTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
public function _before() {
|
||||
$this->woocommerce_segment = $this->createMock(WooCommerceSegment::class);
|
||||
$this->woocommerce_helper = $this->createMock(WooCommerceHelper::class);
|
||||
$this->worker = new WooCommerceSync($this->woocommerce_segment, $this->woocommerce_helper, microtime(true));
|
||||
}
|
||||
|
||||
function testItWillNotRunIfWooCommerceIsDisabled() {
|
||||
public function testItWillNotRunIfWooCommerceIsDisabled() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')
|
||||
->willReturn(false);
|
||||
expect($this->worker->checkProcessingRequirements())->false();
|
||||
}
|
||||
|
||||
function testItWillRunIfWooCommerceIsEnabled() {
|
||||
public function testItWillRunIfWooCommerceIsEnabled() {
|
||||
$this->woocommerce_helper->method('isWooCommerceActive')
|
||||
->willReturn(true);
|
||||
expect($this->worker->checkProcessingRequirements())->true();
|
||||
}
|
||||
|
||||
function testItCallsWooCommerceSync() {
|
||||
public function testItCallsWooCommerceSync() {
|
||||
$this->woocommerce_segment->expects($this->once())
|
||||
->method('synchronizeCustomers');
|
||||
$task = $this->createScheduledTask();
|
||||
@@ -44,7 +44,7 @@ class WooCommerceSyncTest extends \MailPoetTest {
|
||||
return $task;
|
||||
}
|
||||
|
||||
function _after() {
|
||||
public function _after() {
|
||||
ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user