Fix various undefined variables and argument types [MAILPOET-2488]
This commit is contained in:
@ -87,7 +87,7 @@ class Bridge {
|
|||||||
* @param string $key
|
* @param string $key
|
||||||
* @return API
|
* @return API
|
||||||
*/
|
*/
|
||||||
private function getApi($key) {
|
public function getApi($key) {
|
||||||
$this->initApi($key);
|
$this->initApi($key);
|
||||||
assert($this->api instanceof API);
|
assert($this->api instanceof API);
|
||||||
return $this->api;
|
return $this->api;
|
||||||
|
@ -249,8 +249,8 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItCanRun() {
|
public function testItCanRun() {
|
||||||
ignore_user_abort(0);
|
ignore_user_abort(false);
|
||||||
expect(ignore_user_abort())->equals(0);
|
expect(ignore_user_abort())->equals(false);
|
||||||
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
||||||
'pauseExecution' => null,
|
'pauseExecution' => null,
|
||||||
// daemon should call itself
|
// daemon should call itself
|
||||||
@ -268,7 +268,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
|||||||
$daemon = new Daemon($this->cron_helper, $cron_worker_runner_mock, $this->createWorkersFactoryMock());
|
$daemon = new Daemon($this->cron_helper, $cron_worker_runner_mock, $this->createWorkersFactoryMock());
|
||||||
$daemon_http_runner->__construct($daemon, $this->cron_helper, SettingsController::getInstance(), $this->di_container->get(WordPress::class));
|
$daemon_http_runner->__construct($daemon, $this->cron_helper, SettingsController::getInstance(), $this->di_container->get(WordPress::class));
|
||||||
$daemon_http_runner->run($data);
|
$daemon_http_runner->run($data);
|
||||||
expect(ignore_user_abort())->equals(1);
|
expect(ignore_user_abort())->equals(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItRespondsToPingRequest() {
|
public function testItRespondsToPingRequest() {
|
||||||
|
@ -29,8 +29,8 @@ class SimpleWorkerTest extends \MailPoetTest {
|
|||||||
[],
|
[],
|
||||||
$this
|
$this
|
||||||
);
|
);
|
||||||
try {
|
|
||||||
$worker_class = get_class($worker);
|
$worker_class = get_class($worker);
|
||||||
|
try {
|
||||||
new $worker_class();
|
new $worker_class();
|
||||||
$this->fail('SimpleWorker did not throw an exception');
|
$this->fail('SimpleWorker did not throw an exception');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -132,7 +132,7 @@ class JsonTypesTest extends \MailPoetTest {
|
|||||||
|
|
||||||
public function testItDoesNotSaveInvalidData() {
|
public function testItDoesNotSaveInvalidData() {
|
||||||
$entity = new JsonEntity();
|
$entity = new JsonEntity();
|
||||||
$entity->setJsonData("\xB1\x31"); // invalid unicode sequence
|
$entity->setJsonData(["\xB1\x31"]); // invalid unicode sequence
|
||||||
$this->entity_manager->persist($entity);
|
$this->entity_manager->persist($entity);
|
||||||
|
|
||||||
$exception = null;
|
$exception = null;
|
||||||
|
@ -36,7 +36,7 @@ class SendingNewslettersSubscribersFinderTest extends \MailPoetTest {
|
|||||||
->method('load');
|
->method('load');
|
||||||
$segment = Segment::create();
|
$segment = Segment::create();
|
||||||
$segment->type = Segment::TYPE_DEFAULT;
|
$segment->type = Segment::TYPE_DEFAULT;
|
||||||
$segment->id = 3;
|
$segment->id = '3';
|
||||||
$result = $this->subscribers_in_segments_finder->findSubscribersInSegment($segment, []);
|
$result = $this->subscribers_in_segments_finder->findSubscribersInSegment($segment, []);
|
||||||
expect($result)->count(0);
|
expect($result)->count(0);
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,7 @@ class MailerLogTest extends \MailPoetTest {
|
|||||||
public function testItPausesSendingAfterProcessingSendingError() {
|
public function testItPausesSendingAfterProcessingSendingError() {
|
||||||
$mailer_log = MailerLog::getMailerLog();
|
$mailer_log = MailerLog::getMailerLog();
|
||||||
expect($mailer_log['error'])->null();
|
expect($mailer_log['error'])->null();
|
||||||
|
$error = null;
|
||||||
try {
|
try {
|
||||||
MailerLog::processError($operation = 'send', $error = 'email rejected - sending paused', $error_code = null, $pause_sending = true);
|
MailerLog::processError($operation = 'send', $error = 'email rejected - sending paused', $error_code = null, $pause_sending = true);
|
||||||
$this->fail('Paused sending exception was not thrown.');
|
$this->fail('Paused sending exception was not thrown.');
|
||||||
|
@ -752,6 +752,9 @@ class SubscriberTest extends \MailPoetTest {
|
|||||||
// create 3 subscribers, segments and subscriber-segment relations
|
// create 3 subscribers, segments and subscriber-segment relations
|
||||||
$prepare_data = function() {
|
$prepare_data = function() {
|
||||||
$this->_after();
|
$this->_after();
|
||||||
|
$subscriber = [];
|
||||||
|
$segment = [];
|
||||||
|
$subscriber_segment = [];
|
||||||
for ($i = 1; $i <= 3; $i++) {
|
for ($i = 1; $i <= 3; $i++) {
|
||||||
$subscriber[$i] = Subscriber::create();
|
$subscriber[$i] = Subscriber::create();
|
||||||
$subscriber[$i]->status = Subscriber::STATUS_SUBSCRIBED;
|
$subscriber[$i]->status = Subscriber::STATUS_SUBSCRIBED;
|
||||||
|
@ -39,7 +39,7 @@ class LinksTest extends \MailPoetTest {
|
|||||||
$link = NewsletterLink::create();
|
$link = NewsletterLink::create();
|
||||||
$link->newsletter_id = 3;
|
$link->newsletter_id = 3;
|
||||||
$link->queue_id = 3;
|
$link->queue_id = 3;
|
||||||
$link->hash = 123;
|
$link->hash = '123';
|
||||||
$link->url = 'http://example.com';
|
$link->url = 'http://example.com';
|
||||||
$link->save();
|
$link->save();
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ class LinksTest extends \MailPoetTest {
|
|||||||
$links = [
|
$links = [
|
||||||
[
|
[
|
||||||
'link' => 'http://example.com',
|
'link' => 'http://example.com',
|
||||||
'hash' => 123,
|
'hash' => '123',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
Links::save(
|
Links::save(
|
||||||
@ -187,7 +187,7 @@ class LinksTest extends \MailPoetTest {
|
|||||||
$newsltter_link = NewsletterLink::where('newsletter_id', 1)
|
$newsltter_link = NewsletterLink::where('newsletter_id', 1)
|
||||||
->where('queue_id', 1)
|
->where('queue_id', 1)
|
||||||
->findOne();
|
->findOne();
|
||||||
expect($newsltter_link->hash)->equals(123);
|
expect($newsltter_link->hash)->equals('123');
|
||||||
expect($newsltter_link->url)->equals('http://example.com');
|
expect($newsltter_link->url)->equals('http://example.com');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,21 +195,21 @@ class LinksTest extends \MailPoetTest {
|
|||||||
$link = NewsletterLink::create();
|
$link = NewsletterLink::create();
|
||||||
$link->newsletter_id = 1;
|
$link->newsletter_id = 1;
|
||||||
$link->queue_id = 2;
|
$link->queue_id = 2;
|
||||||
$link->hash = 123;
|
$link->hash = '123';
|
||||||
$link->url = 'http://example.com';
|
$link->url = 'http://example.com';
|
||||||
$link->save();
|
$link->save();
|
||||||
|
|
||||||
$link = NewsletterLink::create();
|
$link = NewsletterLink::create();
|
||||||
$link->newsletter_id = 1;
|
$link->newsletter_id = 1;
|
||||||
$link->queue_id = 3;
|
$link->queue_id = 3;
|
||||||
$link->hash = 456;
|
$link->hash = '456';
|
||||||
$link->url = 'http://demo.com';
|
$link->url = 'http://demo.com';
|
||||||
$link->save();
|
$link->save();
|
||||||
|
|
||||||
list($content, $links) = Links::process('<a href="http://example.com">x</a>', 1, 2);
|
list($content, $links) = Links::process('<a href="http://example.com">x</a>', 1, 2);
|
||||||
expect(is_array($links))->true();
|
expect(is_array($links))->true();
|
||||||
expect(count($links))->equals(1);
|
expect(count($links))->equals(1);
|
||||||
expect($links[0]['hash'])->equals(123);
|
expect($links[0]['hash'])->equals('123');
|
||||||
expect($links[0]['url'])->equals('http://example.com');
|
expect($links[0]['url'])->equals('http://example.com');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ class RendererTest extends \MailPoetTest {
|
|||||||
$column_content
|
$column_content
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$rendered_column_content = [];
|
||||||
foreach ($DOM('table.mailpoet_cols-one > tbody') as $column) {
|
foreach ($DOM('table.mailpoet_cols-one > tbody') as $column) {
|
||||||
$rendered_column_content[] = trim($column->text());
|
$rendered_column_content[] = trim($column->text());
|
||||||
};
|
};
|
||||||
@ -101,6 +102,7 @@ class RendererTest extends \MailPoetTest {
|
|||||||
$column_content
|
$column_content
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$rendered_column_content = [];
|
||||||
foreach ($DOM('table.mailpoet_cols-two > tbody') as $column) {
|
foreach ($DOM('table.mailpoet_cols-two > tbody') as $column) {
|
||||||
$rendered_column_content[] = trim($column->text());
|
$rendered_column_content[] = trim($column->text());
|
||||||
};
|
};
|
||||||
@ -128,6 +130,7 @@ class RendererTest extends \MailPoetTest {
|
|||||||
$column_content
|
$column_content
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
$rendered_column_content = [];
|
||||||
foreach ($DOM('table.mailpoet_cols-three > tbody') as $column) {
|
foreach ($DOM('table.mailpoet_cols-three > tbody') as $column) {
|
||||||
$rendered_column_content[] = trim($column->text());
|
$rendered_column_content[] = trim($column->text());
|
||||||
};
|
};
|
||||||
|
@ -67,8 +67,7 @@ class BridgeTest extends \MailPoetTest {
|
|||||||
|
|
||||||
public function testItInstantiatesDefaultAPI() {
|
public function testItInstantiatesDefaultAPI() {
|
||||||
$this->bridge->api = null;
|
$this->bridge->api = null;
|
||||||
$this->bridge->initApi(null);
|
expect($this->bridge->getApi('key') instanceof API)->true();
|
||||||
expect($this->bridge->api instanceof API)->true();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItChecksValidMSSKey() {
|
public function testItChecksValidMSSKey() {
|
||||||
|
@ -80,7 +80,7 @@ class ClicksTest extends \MailPoetTest {
|
|||||||
], $this);
|
], $this);
|
||||||
$data = $this->track_data;
|
$data = $this->track_data;
|
||||||
// 1. when tracking data does not exist
|
// 1. when tracking data does not exist
|
||||||
$clicks->track(false);
|
$clicks->track(null);
|
||||||
// 2. when link model object is missing
|
// 2. when link model object is missing
|
||||||
unset($data->link);
|
unset($data->link);
|
||||||
$clicks->track($data);
|
$clicks->track($data);
|
||||||
|
@ -71,7 +71,7 @@ class ConflictResolverTest extends \MailPoetTest {
|
|||||||
$permitted_asset_location = $this->conflict_resolver->permitted_assets_locations['scripts'][array_rand($this->conflict_resolver->permitted_assets_locations['scripts'], 1)];
|
$permitted_asset_location = $this->conflict_resolver->permitted_assets_locations['scripts'][array_rand($this->conflict_resolver->permitted_assets_locations['scripts'], 1)];
|
||||||
// enqueue scripts
|
// enqueue scripts
|
||||||
wp_enqueue_script('select2', '/wp-content/some/offending/plugin/select2.js');
|
wp_enqueue_script('select2', '/wp-content/some/offending/plugin/select2.js');
|
||||||
wp_enqueue_script('some_random_script', 'http://example.com/some_script.js', null, null, $in_footer = true); // test inside footer
|
wp_enqueue_script('some_random_script', 'http://example.com/some_script.js', [], null, $in_footer = true); // test inside footer
|
||||||
wp_enqueue_script('permitted_script', trim($permitted_asset_location, '^'));
|
wp_enqueue_script('permitted_script', trim($permitted_asset_location, '^'));
|
||||||
$this->conflict_resolver->resolveScriptsConflict();
|
$this->conflict_resolver->resolveScriptsConflict();
|
||||||
do_action('wp_print_scripts');
|
do_action('wp_print_scripts');
|
||||||
|
Reference in New Issue
Block a user