Add space between catch and ‘(‘

[MAILPOET-1791]
This commit is contained in:
Ján Mikláš
2019-02-13 12:57:42 +01:00
committed by M. Shull
parent a8972ca281
commit 9e9561e576
50 changed files with 115 additions and 115 deletions

View File

@ -172,7 +172,7 @@ class API {
} }
$response = $endpoint->{$this->_request_method}($this->_request_data); $response = $endpoint->{$this->_request_method}($this->_request_data);
return $response; return $response;
} catch(\Exception $e) { } catch (\Exception $e) {
$error_message = $e->getMessage(); $error_message = $e->getMessage();
$error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST); $error_response = $this->createErrorResponse(Error::BAD_REQUEST, $error_message, Response::STATUS_BAD_REQUEST);
return $error_response; return $error_response;

View File

@ -293,7 +293,7 @@ class Forms extends APIEndpoint {
try { try {
$meta = $this->bulk_action->apply('\MailPoet\Models\Form', $data); $meta = $this->bulk_action->apply('\MailPoet\Models\Form', $data);
return $this->successResponse(null, $meta); return $this->successResponse(null, $meta);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -19,7 +19,7 @@ class ImportExport extends APIEndpoint {
$mailChimp = new MailChimp($data['api_key']); $mailChimp = new MailChimp($data['api_key']);
$lists = $mailChimp->getLists(); $lists = $mailChimp->getLists();
return $this->successResponse($lists); return $this->successResponse($lists);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -31,7 +31,7 @@ class ImportExport extends APIEndpoint {
$mailChimp = new MailChimp($data['api_key']); $mailChimp = new MailChimp($data['api_key']);
$subscribers = $mailChimp->getSubscribers($data['lists']); $subscribers = $mailChimp->getSubscribers($data['lists']);
return $this->successResponse($subscribers); return $this->successResponse($subscribers);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -58,7 +58,7 @@ class ImportExport extends APIEndpoint {
); );
$process = $import->process(); $process = $import->process();
return $this->successResponse($process); return $this->successResponse($process);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -72,7 +72,7 @@ class ImportExport extends APIEndpoint {
); );
$process = $export->process(); $process = $export->process();
return $this->successResponse($process); return $this->successResponse($process);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -27,7 +27,7 @@ class MP2Migrator extends APIEndpoint {
try { try {
$process = $this->MP2Migrator->import($data); $process = $this->MP2Migrator->import($data);
return $this->successResponse($process); return $this->successResponse($process);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -44,7 +44,7 @@ class MP2Migrator extends APIEndpoint {
try { try {
$process = $this->MP2Migrator->stopImport(); $process = $this->MP2Migrator->stopImport();
return $this->successResponse($process); return $this->successResponse($process);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -61,7 +61,7 @@ class MP2Migrator extends APIEndpoint {
try { try {
$process = $this->MP2Migrator->skipImport(); $process = $this->MP2Migrator->skipImport();
return $this->successResponse($process); return $this->successResponse($process);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -22,7 +22,7 @@ class Mailer extends APIEndpoint {
(isset($data['reply_to'])) ? $data['reply_to'] : false (isset($data['reply_to'])) ? $data['reply_to'] : false
); );
$result = $mailer->send($data['newsletter'], $data['subscriber']); $result = $mailer->send($data['newsletter'], $data['subscriber']);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -394,7 +394,7 @@ class Newsletters extends APIEndpoint {
Newsletter::findOne($id)->asArray() Newsletter::findOne($id)->asArray()
); );
} }
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -464,7 +464,7 @@ class Newsletters extends APIEndpoint {
try { try {
$meta = $this->bulk_action->apply('\MailPoet\Models\Newsletter', $data); $meta = $this->bulk_action->apply('\MailPoet\Models\Newsletter', $data);
return $this->successResponse(null, $meta); return $this->successResponse(null, $meta);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -150,7 +150,7 @@ class Segments extends APIEndpoint {
function synchronize() { function synchronize() {
try { try {
WP::synchronizeUsers(); WP::synchronizeUsers();
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -163,7 +163,7 @@ class Segments extends APIEndpoint {
try { try {
$meta = $this->bulk_action->apply('\MailPoet\Models\Segment', $data); $meta = $this->bulk_action->apply('\MailPoet\Models\Segment', $data);
return $this->successResponse(null, $meta); return $this->successResponse(null, $meta);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -36,7 +36,7 @@ class SendingQueue extends APIEndpoint {
// check that the sending method has been configured properly // check that the sending method has been configured properly
try { try {
new \MailPoet\Mailer\Mailer(false); new \MailPoet\Mailer\Mailer(false);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -37,7 +37,7 @@ class Services extends APIEndpoint {
try { try {
$result = $this->bridge->checkMSSKey($key); $result = $this->bridge->checkMSSKey($key);
$this->bridge->storeMSSKeyAndState($key, $result); $this->bridge->storeMSSKeyAndState($key, $result);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));
@ -99,7 +99,7 @@ class Services extends APIEndpoint {
try { try {
$result = $this->bridge->checkPremiumKey($key); $result = $this->bridge->checkPremiumKey($key);
$this->bridge->storePremiumKeyAndState($key, $result); $this->bridge->storePremiumKeyAndState($key, $result);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -27,7 +27,7 @@ class Setup extends APIEndpoint {
$activator->activate(); $activator->activate();
$this->wp->doAction('mailpoet_setup_reset'); $this->wp->doAction('mailpoet_setup_reset');
return $this->successResponse(); return $this->successResponse();
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -300,7 +300,7 @@ class Subscribers extends APIEndpoint {
$bulk_action = new BulkAction($data); $bulk_action = new BulkAction($data);
return $this->successResponse(null, $bulk_action->apply()); return $this->successResponse(null, $bulk_action->apply());
} }
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->errorResponse(array( return $this->errorResponse(array(
$e->getCode() => $e->getMessage() $e->getCode() => $e->getMessage()
)); ));

View File

@ -47,7 +47,7 @@ class Initializer {
try { try {
$this->setupDB(); $this->setupDB();
} catch(\Exception $e) { } catch (\Exception $e) {
return WPNotice::displayError(Helpers::replaceLinkTags( return WPNotice::displayError(Helpers::replaceLinkTags(
__('Unable to connect to the database (the database is unable to open a file or folder), the connection is likely not configured correctly. Please read our [link] Knowledge Base article [/link] for steps how to resolve it.', 'mailpoet'), __('Unable to connect to the database (the database is unable to open a file or folder), the connection is likely not configured correctly. Please read our [link] Knowledge Base article [/link] for steps how to resolve it.', 'mailpoet'),
'//beta.docs.mailpoet.com/article/200-solving-database-connection-issues', '//beta.docs.mailpoet.com/article/200-solving-database-connection-issues',
@ -120,7 +120,7 @@ class Initializer {
try { try {
$this->setupRenderer(); $this->setupRenderer();
$this->setupWidget(); $this->setupWidget();
} catch(\Exception $e) { } catch (\Exception $e) {
$this->handleFailedInitialization($e); $this->handleFailedInitialization($e);
} }
} }
@ -158,7 +158,7 @@ class Initializer {
$this->setupDeactivationSurvey(); $this->setupDeactivationSurvey();
do_action('mailpoet_initialized', MAILPOET_VERSION); do_action('mailpoet_initialized', MAILPOET_VERSION);
} catch(\Exception $e) { } catch (\Exception $e) {
return $this->handleFailedInitialization($e); return $this->handleFailedInitialization($e);
} }
@ -168,7 +168,7 @@ class Initializer {
function maybeDbUpdate() { function maybeDbUpdate() {
try { try {
$current_db_version = $this->container->get(SettingsController::class)->get('db_version'); $current_db_version = $this->container->get(SettingsController::class)->get('db_version');
} catch(\Exception $e) { } catch (\Exception $e) {
$current_db_version = null; $current_db_version = null;
} }
@ -252,7 +252,7 @@ class Initializer {
$this->setupJSONAPI(); $this->setupJSONAPI();
$this->setupRouter(); $this->setupRouter();
$this->setupUserLocale(); $this->setupUserLocale();
} catch(\Exception $e) { } catch (\Exception $e) {
$this->handleFailedInitialization($e); $this->handleFailedInitialization($e);
} }
} }

View File

@ -852,7 +852,7 @@ class Menu {
function displayPage($template, $data) { function displayPage($template, $data) {
try { try {
echo $this->renderer->render($template, $data); echo $this->renderer->render($template, $data);
} catch(\Exception $e) { } catch (\Exception $e) {
$notice = new WPNotice(WPNotice::TYPE_ERROR, $e->getMessage()); $notice = new WPNotice(WPNotice::TYPE_ERROR, $e->getMessage());
$notice->displayWPNotice(); $notice->displayWPNotice();
} }

View File

@ -107,7 +107,7 @@ class Renderer {
function render($template, $context = array()) { function render($template, $context = array()) {
try { try {
return $this->renderer->render($template, $context); return $this->renderer->render($template, $context);
} catch(\RuntimeException $e) { } catch (\RuntimeException $e) {
throw new \Exception(sprintf( throw new \Exception(sprintf(
__('Failed to render template "%s". Please ensure the template cache folder "%s" exists and has write permissions. Terminated with error: "%s"'), __('Failed to render template "%s". Please ensure the template cache folder "%s" exists and has write permissions. Terminated with error: "%s"'),
$template, $template,

View File

@ -156,7 +156,7 @@ class RequirementsChecker {
try { try {
$reflector = new \ReflectionClass($namespaced_class); $reflector = new \ReflectionClass($namespaced_class);
return $reflector->getFileName(); return $reflector->getFileName();
} catch(\ReflectionException $ex) { } catch (\ReflectionException $ex) {
return false; return false;
} }
} }

View File

@ -27,7 +27,7 @@ class CronTrigger {
return (class_exists($trigger_class)) ? return (class_exists($trigger_class)) ?
$trigger_class::run() : $trigger_class::run() :
false; false;
} catch(\Exception $e) { } catch (\Exception $e) {
// cron exceptions should not prevent the rest of the site from loading // cron exceptions should not prevent the rest of the site from loading
} }
} }

View File

@ -28,7 +28,7 @@ class Daemon {
$this->executePremiumKeyCheckWorker(); $this->executePremiumKeyCheckWorker();
$this->executeBounceWorker(); $this->executeBounceWorker();
// TODO: execute WooCommerceSync worker // TODO: execute WooCommerceSync worker
} catch(\Exception $e) { } catch (\Exception $e) {
CronHelper::saveDaemonLastError($e->getMessage()); CronHelper::saveDaemonLastError($e->getMessage());
} }
// Log successful execution // Log successful execution

View File

@ -46,7 +46,7 @@ class Worker {
foreach (self::getDueTasks() as $task) { foreach (self::getDueTasks() as $task) {
try { try {
$this->mailer->send($this->constructNewsletter($task), $settings['address']); $this->mailer->send($this->constructNewsletter($task), $settings['address']);
} catch(\Exception $e) { } catch (\Exception $e) {
if(WP_DEBUG) { if(WP_DEBUG) {
throw $e; throw $e;
} }

View File

@ -281,7 +281,7 @@ class Date extends Base {
if($datetime !== false && !empty($datetime)) { if($datetime !== false && !empty($datetime)) {
try { try {
$datetime = Carbon::parse($datetime)->toDateTimeString(); $datetime = Carbon::parse($datetime)->toDateTimeString();
} catch(\Exception $e) { } catch (\Exception $e) {
$datetime = false; $datetime = false;
} }
} }

View File

@ -89,7 +89,7 @@ class Widget extends \WP_Widget {
try { try {
echo $this->renderer->render('form/iframe.html', $data); echo $this->renderer->render('form/iframe.html', $data);
} catch(\Exception $e) { } catch (\Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
@ -328,7 +328,7 @@ EOL;
$output = $renderer->render('form/widget.html', $data); $output = $renderer->render('form/widget.html', $data);
$output = do_shortcode($output); $output = do_shortcode($output);
$output = $this->wp->applyFilters('mailpoet_form_widget_post_process', $output); $output = $this->wp->applyFilters('mailpoet_form_widget_post_process', $output);
} catch(\Exception $e) { } catch (\Exception $e) {
$output = $e->getMessage(); $output = $e->getMessage();
} }
} }

View File

@ -72,7 +72,7 @@ class AmazonSES {
$this->url, $this->url,
$this->request($newsletter, $subscriber, $extra_params) $this->request($newsletter, $subscriber, $extra_params)
); );
} catch(\Exception $e) { } catch (\Exception $e) {
$error = $this->error_mapper->getErrorFromException($e, $subscriber); $error = $this->error_mapper->getErrorFromException($e, $subscriber);
return Mailer::formatMailerErrorResult($error); return Mailer::formatMailerErrorResult($error);
} }

View File

@ -32,7 +32,7 @@ class PHPMail {
try { try {
$mailer = $this->configureMailerWithMessage($newsletter, $subscriber, $extra_params); $mailer = $this->configureMailerWithMessage($newsletter, $subscriber, $extra_params);
$result = $mailer->send(); $result = $mailer->send();
} catch(\Exception $e) { } catch (\Exception $e) {
return Mailer::formatMailerErrorResult($this->error_mapper->getErrorFromException($e, $subscriber)); return Mailer::formatMailerErrorResult($this->error_mapper->getErrorFromException($e, $subscriber));
} }
if($result === true) { if($result === true) {

View File

@ -51,7 +51,7 @@ class SMTP {
try { try {
$message = $this->createMessage($newsletter, $subscriber, $extra_params); $message = $this->createMessage($newsletter, $subscriber, $extra_params);
$result = $this->mailer->send($message); $result = $this->mailer->send($message);
} catch(\Exception $e) { } catch (\Exception $e) {
return Mailer::formatMailerErrorResult( return Mailer::formatMailerErrorResult(
$this->error_mapper->getErrorFromException($e, $subscriber) $this->error_mapper->getErrorFromException($e, $subscriber)
); );

View File

@ -197,9 +197,9 @@ class Model extends \Sudzy\ValidModel {
$this->_new_record = $this->isNew(); $this->_new_record = $this->isNew();
try { try {
parent::save(); parent::save();
} catch(\Sudzy\ValidationException $e) { } catch (\Sudzy\ValidationException $e) {
$this->setError($e->getValidationErrors()); $this->setError($e->getValidationErrors());
} catch(\PDOException $e) { } catch (\PDOException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 23000: case 23000:
preg_match("/for key \'(.*?)\'/i", $e->getMessage(), $matches); preg_match("/for key \'(.*?)\'/i", $e->getMessage(), $matches);
@ -330,7 +330,7 @@ class Model extends \Sudzy\ValidModel {
public static function __callStatic($method, $parameters) { public static function __callStatic($method, $parameters) {
try { try {
return parent::__callStatic($method, $parameters); return parent::__callStatic($method, $parameters);
} catch(\PDOException $e) { } catch (\PDOException $e) {
throw new \Exception($e->getMessage()); throw new \Exception($e->getMessage());
} }
} }

View File

@ -103,7 +103,7 @@ class ScheduledTask extends Model {
ScheduledTaskSubscriber::where('task_id', $this->id)->deleteMany(); ScheduledTaskSubscriber::where('task_id', $this->id)->deleteMany();
parent::delete(); parent::delete();
\ORM::get_db()->commit(); \ORM::get_db()->commit();
} catch(\Exception $error) { } catch (\Exception $error) {
\ORM::get_db()->rollBack(); \ORM::get_db()->rollBack();
throw $error; throw $error;
} }

View File

@ -233,7 +233,7 @@ class Scheduler {
$schedule = \Cron\CronExpression::factory($schedule); $schedule = \Cron\CronExpression::factory($schedule);
$next_run_date = $schedule->getNextRunDate(Carbon::createFromTimestamp($from_timestamp)) $next_run_date = $schedule->getNextRunDate(Carbon::createFromTimestamp($from_timestamp))
->format('Y-m-d H:i:s'); ->format('Y-m-d H:i:s');
} catch(\Exception $e) { } catch (\Exception $e) {
$next_run_date = false; $next_run_date = false;
} }
return $next_run_date; return $next_run_date;
@ -246,7 +246,7 @@ class Scheduler {
$schedule = \Cron\CronExpression::factory($schedule); $schedule = \Cron\CronExpression::factory($schedule);
$previous_run_date = $schedule->getPreviousRunDate(Carbon::createFromTimestamp($from_timestamp)) $previous_run_date = $schedule->getPreviousRunDate(Carbon::createFromTimestamp($from_timestamp))
->format('Y-m-d H:i:s'); ->format('Y-m-d H:i:s');
} catch(\Exception $e) { } catch (\Exception $e) {
$previous_run_date = false; $previous_run_date = false;
} }
return $previous_run_date; return $previous_run_date;

View File

@ -43,7 +43,7 @@ class Bridge {
$mailer_config = Mailer::getMailerConfig(); $mailer_config = Mailer::getMailerConfig();
return !empty($mailer_config['method']) return !empty($mailer_config['method'])
&& $mailer_config['method'] === Mailer::METHOD_MAILPOET; && $mailer_config['method'] === Mailer::METHOD_MAILPOET;
} catch(\Exception $e) { } catch (\Exception $e) {
return false; return false;
} }
} }

View File

@ -103,7 +103,7 @@ class ConfirmationEmailMailer {
$this->mailer->getSenderNameAndAddress($from); $this->mailer->getSenderNameAndAddress($from);
$this->mailer->getReplyToNameAndAddress($reply_to); $this->mailer->getReplyToNameAndAddress($reply_to);
return $this->mailer->send($email, $subscriber); return $this->mailer->send($email, $subscriber);
} catch(\Exception $e) { } catch (\Exception $e) {
$subscriber->setError($e->getMessage()); $subscriber->setError($e->getMessage());
return false; return false;
} }

View File

@ -64,7 +64,7 @@ class Export {
'generate' . strtoupper($this->export_format_option) 'generate' . strtoupper($this->export_format_option)
) )
); );
} catch(\Exception $e) { } catch (\Exception $e) {
throw new \Exception($e->getMessage()); throw new \Exception($e->getMessage());
} }
return array( return array(

View File

@ -129,7 +129,7 @@ class Import {
$this->synchronizeWPUsers($wp_users); $this->synchronizeWPUsers($wp_users);
} }
} }
} catch(\Exception $e) { } catch (\Exception $e) {
throw new \Exception(__('Unable to save imported subscribers.', 'mailpoet')); throw new \Exception(__('Unable to save imported subscribers.', 'mailpoet'));
} }

View File

@ -65,7 +65,7 @@ class NewSubscriberNotificationMailer {
try { try {
$this->mailer->getSenderNameAndAddress($this->constructSenderEmail()); $this->mailer->getSenderNameAndAddress($this->constructSenderEmail());
$this->mailer->send($this->constructNewsletter($subscriber, $segments), $settings['address']); $this->mailer->send($this->constructNewsletter($subscriber, $segments), $settings['address']);
} catch(\Exception $e) { } catch (\Exception $e) {
if(WP_DEBUG) { if(WP_DEBUG) {
throw $e; throw $e;
} }

View File

@ -14,7 +14,7 @@ class APITest extends \MailPoetTest {
try { try {
API::MP('invalid_version'); API::MP('invalid_version');
$this->fail('Incorrect API version exception should have been thrown.'); $this->fail('Incorrect API version exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Invalid API version.'); expect($e->getMessage())->equals('Invalid API version.');
} }
} }

View File

@ -534,7 +534,7 @@ class SubscribersTest extends \MailPoetTest {
$this->obfuscatedSegments => array($this->segment_1->id, $this->segment_2->id) $this->obfuscatedSegments => array($this->segment_1->id, $this->segment_2->id)
)); ));
$this->fail('It should not be possible to subscribe a second time so soon'); $this->fail('It should not be possible to subscribe a second time so soon');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('You need to wait 60 seconds before subscribing again.'); expect($e->getMessage())->equals('You need to wait 60 seconds before subscribing again.');
} }
} }
@ -561,7 +561,7 @@ class SubscribersTest extends \MailPoetTest {
$this->obfuscatedSegments => array($this->segment_1->id, $this->segment_2->id) $this->obfuscatedSegments => array($this->segment_1->id, $this->segment_2->id)
)); ));
$this->fail('It should not be possible to resubscribe a second time so soon'); $this->fail('It should not be possible to resubscribe a second time so soon');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('You need to wait 60 seconds before subscribing again.'); expect($e->getMessage())->equals('You need to wait 60 seconds before subscribing again.');
} }
} }

View File

@ -61,7 +61,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->subscribeToLists(false, array(1,2,3)); $this->getApi()->subscribeToLists(false, array(1,2,3));
$this->fail('Subscriber does not exist exception should have been thrown.'); $this->fail('Subscriber does not exist exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('This subscriber does not exist.'); expect($e->getMessage())->equals('This subscriber does not exist.');
} }
} }
@ -74,14 +74,14 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->subscribeToLists($subscriber->id, array(1,2,3)); $this->getApi()->subscribeToLists($subscriber->id, array(1,2,3));
$this->fail('Missing segments exception should have been thrown.'); $this->fail('Missing segments exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('These lists do not exist.'); expect($e->getMessage())->equals('These lists do not exist.');
} }
// single list error message // single list error message
try { try {
$this->getApi()->subscribeToLists($subscriber->id, array(1)); $this->getApi()->subscribeToLists($subscriber->id, array(1));
$this->fail('Missing segments exception should have been thrown.'); $this->fail('Missing segments exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('This list does not exist.'); expect($e->getMessage())->equals('This list does not exist.');
} }
} }
@ -99,7 +99,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->subscribeToLists($subscriber->id, array($segment->id)); $this->getApi()->subscribeToLists($subscriber->id, array($segment->id));
$this->fail('WP Users segment exception should have been thrown.'); $this->fail('WP Users segment exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals("Can't subscribe to a WordPress Users list with ID {$segment->id}."); expect($e->getMessage())->equals("Can't subscribe to a WordPress Users list with ID {$segment->id}.");
} }
} }
@ -117,7 +117,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->subscribeToLists($subscriber->id, array($segment->id)); $this->getApi()->subscribeToLists($subscriber->id, array($segment->id));
$this->fail('WooCommerce Customers segment exception should have been thrown.'); $this->fail('WooCommerce Customers segment exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals("Can't subscribe to a WooCommerce Customers list with ID {$segment->id}."); expect($e->getMessage())->equals("Can't subscribe to a WooCommerce Customers list with ID {$segment->id}.");
} }
} }
@ -136,14 +136,14 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->subscribeToLists($subscriber->id, array($segment->id, 90, 100)); $this->getApi()->subscribeToLists($subscriber->id, array($segment->id, 90, 100));
$this->fail('Missing segments with IDs exception should have been thrown.'); $this->fail('Missing segments with IDs exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Lists with IDs 90, 100 do not exist.'); expect($e->getMessage())->equals('Lists with IDs 90, 100 do not exist.');
} }
// single list error message // single list error message
try { try {
$this->getApi()->subscribeToLists($subscriber->id, array($segment->id, 90)); $this->getApi()->subscribeToLists($subscriber->id, array($segment->id, 90));
$this->fail('Missing segments with IDs exception should have been thrown.'); $this->fail('Missing segments with IDs exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('List with ID 90 does not exist.'); expect($e->getMessage())->equals('List with ID 90 does not exist.');
} }
} }
@ -182,7 +182,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->subscribeToLists($subscriber->id, array()); $this->getApi()->subscribeToLists($subscriber->id, array());
$this->fail('Segments are required exception should have been thrown.'); $this->fail('Segments are required exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('At least one segment ID is required.'); expect($e->getMessage())->equals('At least one segment ID is required.');
} }
@ -307,7 +307,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->addSubscriber(array()); $this->getApi()->addSubscriber(array());
$this->fail('Subscriber email address required exception should have been thrown.'); $this->fail('Subscriber email address required exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Subscriber email address is required.'); expect($e->getMessage())->equals('Subscriber email address is required.');
} }
} }
@ -319,7 +319,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->addSubscriber(array('email' => $subscriber->email)); $this->getApi()->addSubscriber(array('email' => $subscriber->email));
$this->fail('Subscriber exists exception should have been thrown.'); $this->fail('Subscriber exists exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('This subscriber already exists.'); expect($e->getMessage())->equals('This subscriber already exists.');
} }
} }
@ -331,7 +331,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->addSubscriber($subscriber); $this->getApi()->addSubscriber($subscriber);
$this->fail('Failed to add subscriber exception should have been thrown.'); $this->fail('Failed to add subscriber exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->contains('Failed to add subscriber:'); expect($e->getMessage())->contains('Failed to add subscriber:');
// error message (converted to lowercase) returned by the model // error message (converted to lowercase) returned by the model
expect($e->getMessage())->contains('your email address is invalid!'); expect($e->getMessage())->contains('your email address is invalid!');
@ -525,7 +525,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->addList(array()); $this->getApi()->addList(array());
$this->fail('List name required exception should have been thrown.'); $this->fail('List name required exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('List name is required.'); expect($e->getMessage())->equals('List name is required.');
} }
} }
@ -537,7 +537,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->addList(array('name' => $segment->name)); $this->getApi()->addList(array('name' => $segment->name));
$this->fail('List exists exception should have been thrown.'); $this->fail('List exists exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('This list already exists.'); expect($e->getMessage())->equals('This list already exists.');
} }
} }
@ -556,7 +556,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->unsubscribeFromLists(false, array(1,2,3)); $this->getApi()->unsubscribeFromLists(false, array(1,2,3));
$this->fail('Subscriber does not exist exception should have been thrown.'); $this->fail('Subscriber does not exist exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('This subscriber does not exist.'); expect($e->getMessage())->equals('This subscriber does not exist.');
} }
} }
@ -569,14 +569,14 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->unsubscribeFromLists($subscriber->id, array(1,2,3)); $this->getApi()->unsubscribeFromLists($subscriber->id, array(1,2,3));
$this->fail('Missing segments exception should have been thrown.'); $this->fail('Missing segments exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('These lists do not exist.'); expect($e->getMessage())->equals('These lists do not exist.');
} }
// single list error message // single list error message
try { try {
$this->getApi()->unsubscribeFromLists($subscriber->id, array(1)); $this->getApi()->unsubscribeFromLists($subscriber->id, array(1));
$this->fail('Missing segments exception should have been thrown.'); $this->fail('Missing segments exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('This list does not exist.'); expect($e->getMessage())->equals('This list does not exist.');
} }
} }
@ -595,14 +595,14 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id, 90, 100)); $this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id, 90, 100));
$this->fail('Missing segments with IDs exception should have been thrown.'); $this->fail('Missing segments with IDs exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Lists with IDs 90, 100 do not exist.'); expect($e->getMessage())->equals('Lists with IDs 90, 100 do not exist.');
} }
// single list error message // single list error message
try { try {
$this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id, 90)); $this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id, 90));
$this->fail('Missing segments with IDs exception should have been thrown.'); $this->fail('Missing segments with IDs exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('List with ID 90 does not exist.'); expect($e->getMessage())->equals('List with ID 90 does not exist.');
} }
} }
@ -620,7 +620,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id)); $this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id));
$this->fail('WP Users segment exception should have been thrown.'); $this->fail('WP Users segment exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals("Can't unsubscribe from a WordPress Users list with ID {$segment->id}."); expect($e->getMessage())->equals("Can't unsubscribe from a WordPress Users list with ID {$segment->id}.");
} }
} }
@ -638,7 +638,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id)); $this->getApi()->unsubscribeFromLists($subscriber->id, array($segment->id));
$this->fail('WooCommerce Customers segment exception should have been thrown.'); $this->fail('WooCommerce Customers segment exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals("Can't unsubscribe from a WooCommerce Customers list with ID {$segment->id}."); expect($e->getMessage())->equals("Can't unsubscribe from a WooCommerce Customers list with ID {$segment->id}.");
} }
} }
@ -676,7 +676,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->unsubscribeFromLists($subscriber->id, array()); $this->getApi()->unsubscribeFromLists($subscriber->id, array());
$this->fail('Segments are required exception should have been thrown.'); $this->fail('Segments are required exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('At least one segment ID is required.'); expect($e->getMessage())->equals('At least one segment ID is required.');
} }
@ -707,7 +707,7 @@ class APITest extends \MailPoetTest {
try { try {
$this->getApi()->getSubscriber('some_fake_email'); $this->getApi()->getSubscriber('some_fake_email');
$this->fail('Subscriber does not exist exception should have been thrown.'); $this->fail('Subscriber does not exist exception should have been thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('This subscriber does not exist.'); expect($e->getMessage())->equals('This subscriber does not exist.');
} }
} }

View File

@ -76,7 +76,7 @@ class DatabaseTest extends \MailPoetTest {
try { try {
$this->database->setupDriverOptions(); $this->database->setupDriverOptions();
$this->fail('Exception was not thrown'); $this->fail('Exception was not thrown');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e instanceof \PDOException)->false(); expect($e instanceof \PDOException)->false();
expect($e->getMessage())->equals($message); expect($e->getMessage())->equals($message);
} }

View File

@ -109,7 +109,7 @@ class RendererTest extends \MailPoetTest {
try { try {
$renderer->render('non-existing-template.html', array('somekey' => 'someval')); $renderer->render('non-existing-template.html', array('somekey' => 'someval'));
self::fail('Twig exception was not rethrown'); self::fail('Twig exception was not rethrown');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->contains($exception_message); expect($e->getMessage())->contains($exception_message);
expect($e->getMessage())->notEquals($exception_message); expect($e->getMessage())->notEquals($exception_message);
} }

View File

@ -240,7 +240,7 @@ class CronHelperTest extends \MailPoetTest {
try { try {
CronHelper::getSiteUrl($site_url); CronHelper::getSiteUrl($site_url);
self::fail('Site URL is unreachable exception not thrown.'); self::fail('Site URL is unreachable exception not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Site URL is unreachable.'); expect($e->getMessage())->equals('Site URL is unreachable.');
} }
} }
@ -257,7 +257,7 @@ class CronHelperTest extends \MailPoetTest {
try { try {
CronHelper::enforceExecutionLimit($time - CronHelper::DAEMON_EXECUTION_LIMIT); CronHelper::enforceExecutionLimit($time - CronHelper::DAEMON_EXECUTION_LIMIT);
self::fail('Execution limit exception not thrown.'); self::fail('Execution limit exception not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Maximum execution time has been reached.'); expect($e->getMessage())->equals('Maximum execution time has been reached.');
} }
} }

View File

@ -37,7 +37,7 @@ class SchedulerTest extends \MailPoetTest {
try { try {
$scheduler = new Scheduler(microtime(true) - CronHelper::DAEMON_EXECUTION_LIMIT); $scheduler = new Scheduler(microtime(true) - CronHelper::DAEMON_EXECUTION_LIMIT);
self::fail('Maximum execution time limit exception was not thrown.'); self::fail('Maximum execution time limit exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Maximum execution time has been reached.'); expect($e->getMessage())->equals('Maximum execution time has been reached.');
} }
} }
@ -525,7 +525,7 @@ class SchedulerTest extends \MailPoetTest {
try { try {
$scheduler->process(); $scheduler->process();
self::fail('Maximum execution time limit exception was not thrown.'); self::fail('Maximum execution time limit exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Maximum execution time has been reached.'); expect($e->getMessage())->equals('Maximum execution time has been reached.');
} }
} }

View File

@ -132,7 +132,7 @@ class SendingQueueTest extends \MailPoetTest {
try { try {
$sending_queue_worker->process(); $sending_queue_worker->process();
self::fail('Execution limits function was not called.'); self::fail('Execution limits function was not called.');
} catch(\Exception $e) { } catch (\Exception $e) {
// No exception handling needed // No exception handling needed
} }
} }
@ -630,7 +630,7 @@ class SendingQueueTest extends \MailPoetTest {
$statistics = [] $statistics = []
); );
$this->fail('Paused sending exception was not thrown.'); $this->fail('Paused sending exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sending has been paused.'); expect($e->getMessage())->equals('Sending has been paused.');
} }
$mailer_log = MailerLog::getMailerLog(); $mailer_log = MailerLog::getMailerLog();

View File

@ -316,7 +316,7 @@ class NewsletterTest extends \MailPoetTest {
try { try {
$this->newsletter_task->preProcessNewsletter($this->newsletter, $queue); $this->newsletter_task->preProcessNewsletter($this->newsletter, $queue);
self::fail('Sending error exception was not thrown.'); self::fail('Sending error exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
$mailer_log = MailerLog::getMailerLog(); $mailer_log = MailerLog::getMailerLog();
expect($mailer_log['error']['operation'])->equals('queue_save'); expect($mailer_log['error']['operation'])->equals('queue_save');
expect($mailer_log['error']['error_message'])->equals('There was an error processing your newsletter during sending. If possible, please contact us and report this issue.'); expect($mailer_log['error']['error_message'])->equals('There was an error processing your newsletter during sending. If possible, please contact us and report this issue.');
@ -334,7 +334,7 @@ class NewsletterTest extends \MailPoetTest {
try { try {
$this->newsletter_task->preProcessNewsletter($this->newsletter, $queue_mock); $this->newsletter_task->preProcessNewsletter($this->newsletter, $queue_mock);
self::fail('Sending error exception was not thrown.'); self::fail('Sending error exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
$mailer_log = MailerLog::getMailerLog(); $mailer_log = MailerLog::getMailerLog();
expect($mailer_log['error']['operation'])->equals('queue_save'); expect($mailer_log['error']['operation'])->equals('queue_save');
expect($mailer_log['error']['error_message'])->equals('There was an error processing your newsletter during sending. If possible, please contact us and report this issue.'); expect($mailer_log['error']['error_message'])->equals('There was an error processing your newsletter during sending. If possible, please contact us and report this issue.');
@ -357,7 +357,7 @@ class NewsletterTest extends \MailPoetTest {
try { try {
$this->newsletter_task->preProcessNewsletter($this->newsletter, $queue_mock); $this->newsletter_task->preProcessNewsletter($this->newsletter, $queue_mock);
self::fail('Sending error exception was not thrown.'); self::fail('Sending error exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
$mailer_log = MailerLog::getMailerLog(); $mailer_log = MailerLog::getMailerLog();
expect($mailer_log['error']['operation'])->equals('queue_save'); expect($mailer_log['error']['operation'])->equals('queue_save');
expect($mailer_log['error']['error_message'])->equals('There was an error processing your newsletter during sending. If possible, please contact us and report this issue.'); expect($mailer_log['error']['error_message'])->equals('There was an error processing your newsletter during sending. If possible, please contact us and report this issue.');

View File

@ -28,7 +28,7 @@ class SimpleWorkerTest extends \MailPoetTest {
$worker_class = get_class($worker); $worker_class = get_class($worker);
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) {
expect($e->getMessage())->equals('Constant TASK_TYPE is not defined on subclass ' . $worker_class); expect($e->getMessage())->equals('Constant TASK_TYPE is not defined on subclass ' . $worker_class);
} }
} }
@ -43,7 +43,7 @@ class SimpleWorkerTest extends \MailPoetTest {
microtime(true) - CronHelper::DAEMON_EXECUTION_LIMIT microtime(true) - CronHelper::DAEMON_EXECUTION_LIMIT
); );
self::fail('Maximum execution time limit exception was not thrown.'); self::fail('Maximum execution time limit exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Maximum execution time has been reached.'); expect($e->getMessage())->equals('Maximum execution time has been reached.');
} }
} }

View File

@ -196,7 +196,7 @@ class MailerLogTest extends \MailPoetTest {
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.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sending has been paused.'); expect($e->getMessage())->equals('Sending has been paused.');
} }
$mailer_log = MailerLog::getMailerLog(); $mailer_log = MailerLog::getMailerLog();
@ -228,7 +228,7 @@ class MailerLogTest extends \MailPoetTest {
try { try {
MailerLog::enforceExecutionRequirements(); MailerLog::enforceExecutionRequirements();
self::fail('Sending frequency exception was not thrown.'); self::fail('Sending frequency exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sending frequency limit has been reached.'); expect($e->getMessage())->equals('Sending frequency limit has been reached.');
} }
} }
@ -250,7 +250,7 @@ class MailerLogTest extends \MailPoetTest {
try { try {
MailerLog::enforceExecutionRequirements(); MailerLog::enforceExecutionRequirements();
self::fail('Sending frequency exception was not thrown.'); self::fail('Sending frequency exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sending frequency limit has been reached.'); expect($e->getMessage())->equals('Sending frequency limit has been reached.');
} }
} }
@ -271,7 +271,7 @@ class MailerLogTest extends \MailPoetTest {
// sending limit exception should not be thrown // sending limit exception should not be thrown
try { try {
MailerLog::enforceExecutionRequirements(); MailerLog::enforceExecutionRequirements();
} catch(\Exception $e) { } catch (\Exception $e) {
self::fail('Sending frequency exception was thrown.'); self::fail('Sending frequency exception was thrown.');
} }
} }
@ -283,7 +283,7 @@ class MailerLogTest extends \MailPoetTest {
try { try {
MailerLog::enforceExecutionRequirements($mailer_log); MailerLog::enforceExecutionRequirements($mailer_log);
self::fail('Sending waiting to be retried exception was not thrown.'); self::fail('Sending waiting to be retried exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sending is waiting to be retried.'); expect($e->getMessage())->equals('Sending is waiting to be retried.');
} }
} }
@ -298,7 +298,7 @@ class MailerLogTest extends \MailPoetTest {
try { try {
MailerLog::enforceExecutionRequirements($mailer_log); MailerLog::enforceExecutionRequirements($mailer_log);
self::fail('Sending paused exception was not thrown.'); self::fail('Sending paused exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sending has been paused.'); expect($e->getMessage())->equals('Sending has been paused.');
} }
$mailer_log = MailerLog::getMailerLog(); $mailer_log = MailerLog::getMailerLog();
@ -324,7 +324,7 @@ class MailerLogTest extends \MailPoetTest {
try { try {
MailerLog::enforceExecutionRequirements($mailer_log); MailerLog::enforceExecutionRequirements($mailer_log);
self::fail('Sending paused exception was not thrown.'); self::fail('Sending paused exception was not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sending has been paused.'); expect($e->getMessage())->equals('Sending has been paused.');
} }
} }

View File

@ -72,7 +72,7 @@ class MailerTest extends \MailPoetTest {
try { try {
$mailer = new Mailer(); $mailer = new Mailer();
$this->fail('Mailer did not throw an exception'); $this->fail('Mailer did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Mailer is not configured.'); expect($e->getMessage())->equals('Mailer is not configured.');
} }
} }
@ -81,7 +81,7 @@ class MailerTest extends \MailPoetTest {
try { try {
$mailer = new Mailer($mailer = $this->mailer); $mailer = new Mailer($mailer = $this->mailer);
$this->fail('Mailer did not throw an exception'); $this->fail('Mailer did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Sender name and email are not configured.'); expect($e->getMessage())->equals('Sender name and email are not configured.');
} }
} }
@ -108,7 +108,7 @@ class MailerTest extends \MailPoetTest {
try { try {
$mailer = new Mailer(array('method' => 'Unknown'), $this->sender); $mailer = new Mailer(array('method' => 'Unknown'), $this->sender);
$this->fail('Mailer did not throw an exception'); $this->fail('Mailer did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Mailing method does not exist.'); expect($e->getMessage())->equals('Mailing method does not exist.');
} }
} }

View File

@ -91,7 +91,7 @@ class AmazonSESTest extends \MailPoetTest {
new AmazonSESMapper() new AmazonSESMapper()
); );
$this->fail('Unsupported region exception was not thrown'); $this->fail('Unsupported region exception was not thrown');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Unsupported Amazon SES region'); expect($e->getMessage())->equals('Unsupported Amazon SES region');
} }
} }

View File

@ -20,7 +20,7 @@ class ModelTest extends \MailPoetTest {
try { try {
$model::findMany(); $model::findMany();
$this->fail('Exception was not thrown'); $this->fail('Exception was not thrown');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e instanceof \PDOException)->false(); expect($e instanceof \PDOException)->false();
expect($e->getMessage())->equals($message); expect($e->getMessage())->equals($message);
} }

View File

@ -197,7 +197,7 @@ class ExportTest extends \MailPoetTest {
$this->export->export_path = '/fake_folder'; $this->export->export_path = '/fake_folder';
$this->export->process(); $this->export->process();
$this->fail('Export did not throw an exception'); $this->fail('Export did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage()) expect($e->getMessage())
->equals("The export file could not be saved on the server."); ->equals("The export file could not be saved on the server.");
} }
@ -208,7 +208,7 @@ class ExportTest extends \MailPoetTest {
$this->export->export_file = $this->export->getExportFile('csv'); $this->export->export_file = $this->export->getExportFile('csv');
$this->export->export_format_option = 'csv'; $this->export->export_format_option = 'csv';
$result = $this->export->process(); $result = $this->export->process();
} catch(\Exception $e) { } catch (\Exception $e) {
$this->fail('Export to .csv process threw an exception'); $this->fail('Export to .csv process threw an exception');
} }
expect($result['totalExported'])->equals(4); expect($result['totalExported'])->equals(4);
@ -218,7 +218,7 @@ class ExportTest extends \MailPoetTest {
$this->export->export_file = $this->export->getExportFile('xlsx'); $this->export->export_file = $this->export->getExportFile('xlsx');
$this->export->export_format_option = 'xlsx'; $this->export->export_format_option = 'xlsx';
$result = $this->export->process(); $result = $this->export->process();
} catch(\Exception $e) { } catch (\Exception $e) {
$this->fail('Export to .xlsx process threw an exception'); $this->fail('Export to .xlsx process threw an exception');
} }
expect($result['totalExported'])->equals(4); expect($result['totalExported'])->equals(4);

View File

@ -73,7 +73,7 @@ class ImportTest extends \MailPoetTest {
try { try {
$this->import->validateImportData($data); $this->import->validateImportData($data);
self::fail('Missing or invalid data exception not thrown.'); self::fail('Missing or invalid data exception not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Missing or invalid import data.'); expect($e->getMessage())->equals('Missing or invalid import data.');
} }
// exception should not be thrown when all fields exist // exception should not be thrown when all fields exist
@ -86,7 +86,7 @@ class ImportTest extends \MailPoetTest {
try { try {
$this->import->validateImportData($data); $this->import->validateImportData($data);
self::fail('Missing or invalid data exception not thrown.'); self::fail('Missing or invalid data exception not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('Missing or invalid import data.'); expect($e->getMessage())->equals('Missing or invalid import data.');
} }
} }
@ -135,7 +135,7 @@ class ImportTest extends \MailPoetTest {
try { try {
$import->process(); $import->process();
self::fail('No valid subscribers found exception not thrown.'); self::fail('No valid subscribers found exception not thrown.');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->equals('No valid subscribers were found.'); expect($e->getMessage())->equals('No valid subscribers were found.');
} }
} }

View File

@ -44,7 +44,7 @@ class MailChimpTest extends \MailPoetTest {
$mailchimp->api_key = false; $mailchimp->api_key = false;
$lists = $mailchimp->getLists(); $lists = $mailchimp->getLists();
$this->fail('MailChimp getLists() did not throw an exception'); $this->fail('MailChimp getLists() did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->contains('Invalid API Key'); expect($e->getMessage())->contains('Invalid API Key');
} }
} }
@ -53,7 +53,7 @@ class MailChimpTest extends \MailPoetTest {
if(getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return; if(getenv('WP_TEST_ENABLE_NETWORK_TESTS') !== 'true') return;
try { try {
$lists = $this->mailchimp->getLists(); $lists = $this->mailchimp->getLists();
} catch(\Exception $e) { } catch (\Exception $e) {
$this->fail('MailChimp getLists() threw an exception'); $this->fail('MailChimp getLists() threw an exception');
} }
expect($lists)->count(2); expect($lists)->count(2);
@ -67,14 +67,14 @@ class MailChimpTest extends \MailPoetTest {
try { try {
$subscribers = $this->mailchimp->getSubscribers(); $subscribers = $this->mailchimp->getSubscribers();
$this->fail('MailChimp getSubscribers() did not throw an exception'); $this->fail('MailChimp getSubscribers() did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->contains('Did not find any valid lists'); expect($e->getMessage())->contains('Did not find any valid lists');
} }
try { try {
$subscribers = $this->mailchimp->getSubscribers(array(12)); $subscribers = $this->mailchimp->getSubscribers(array(12));
$this->fail('MailChimp getSubscribers() did not throw an exception'); $this->fail('MailChimp getSubscribers() did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage())->contains('Did not find any valid lists'); expect($e->getMessage())->contains('Did not find any valid lists');
} }
} }
@ -84,7 +84,7 @@ class MailChimpTest extends \MailPoetTest {
try { try {
$subscribers = $this->mailchimp->getSubscribers(array($this->lists[0])); $subscribers = $this->mailchimp->getSubscribers(array($this->lists[0]));
} catch(\Exception $e) { } catch (\Exception $e) {
$this->fail('MailChimp getSubscribers() threw an exception'); $this->fail('MailChimp getSubscribers() threw an exception');
} }
@ -101,7 +101,7 @@ class MailChimpTest extends \MailPoetTest {
try { try {
$subscribers = $this->mailchimp->getSubscribers($this->lists); $subscribers = $this->mailchimp->getSubscribers($this->lists);
$this->fail('MailChimp getSubscribers() did not throw an exception'); $this->fail('MailChimp getSubscribers() did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage()) expect($e->getMessage())
->contains('The selected lists do not have matching columns (headers)'); ->contains('The selected lists do not have matching columns (headers)');
} }
@ -115,7 +115,7 @@ class MailChimpTest extends \MailPoetTest {
try { try {
$subscribers = $mailchimp->getSubscribers($this->lists); $subscribers = $mailchimp->getSubscribers($this->lists);
$this->fail('MailChimp getSubscribers() did not throw an exception'); $this->fail('MailChimp getSubscribers() did not throw an exception');
} catch(\Exception $e) { } catch (\Exception $e) {
expect($e->getMessage()) expect($e->getMessage())
->contains('The information received from MailChimp is too large for processing'); ->contains('The information received from MailChimp is too large for processing');
} }

View File

@ -38,7 +38,7 @@ class SendingTest extends \MailPoetTest {
try { try {
$sending = SendingTask::create($this->task, $this->queue); $sending = SendingTask::create($this->task, $this->queue);
$this->fail('Exception was not thrown'); $this->fail('Exception was not thrown');
} catch(\Exception $e) { } catch (\Exception $e) {
// No exception handling necessary // No exception handling necessary
} }
} }

View File

@ -23,7 +23,7 @@ class BatchIteratorTest extends \MailPoetTest {
try { try {
$iterator = new BatchIterator(0, 0); $iterator = new BatchIterator(0, 0);
$this->fail('Exception was not thrown'); $this->fail('Exception was not thrown');
} catch(\Exception $e) { } catch (\Exception $e) {
// No exception handling necessary // No exception handling necessary
} }
} }