Add tests for sending error notices
[MAILPOET-1699]
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace MailPoet\Test\DataFactories;
|
||||
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
|
||||
class Settings {
|
||||
@@ -56,4 +57,16 @@ class Settings {
|
||||
$this->settings->set('show_congratulate_after_first_newsletter', 0);
|
||||
return $this;
|
||||
}
|
||||
|
||||
function withSendingMethod($sending_method) {
|
||||
$this->settings->set('mta.method', $sending_method);
|
||||
$this->settings->set('mta_group', $sending_method === Mailer::METHOD_SMTP ? 'smtp' : 'website');
|
||||
}
|
||||
|
||||
function withSendingError($error_message, $operation = 'send') {
|
||||
$this->settings->set('mta_log.status', 'paused');
|
||||
$this->settings->set('mta_log.error.operation', $operation);
|
||||
$this->settings->set('mta_log.error.error_message', $error_message);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
59
tests/acceptance/NewsletterSendingErrorCest.php
Normal file
59
tests/acceptance/NewsletterSendingErrorCest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Test\Acceptance;
|
||||
|
||||
use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Test\DataFactories\Settings;
|
||||
|
||||
require_once __DIR__ . '/../DataFactories/Settings.php';
|
||||
|
||||
class NewsletterSendingErrorCest {
|
||||
function generalErrorNotice(\AcceptanceTester $I) {
|
||||
$I->wantTo('See proper sending error when sending failed');
|
||||
$I->login();
|
||||
|
||||
$errorMessage = 'Error while sending email.';
|
||||
$settings = new Settings();
|
||||
$settings->withSendingMethod(Mailer::METHOD_SMTP);
|
||||
$settings->withSendingError($errorMessage);
|
||||
|
||||
$I->amOnMailpoetPage('Emails');
|
||||
$I->waitForElement('.mailpoet_notice.notice-error div');
|
||||
$I->see('Sending has been paused due to a technical issue with SMTP: ' . $errorMessage, '.notice-error p');
|
||||
$I->see('Check your sending method settings.', '.notice-error p');
|
||||
$I->see('Resume sending', '.notice-error p');
|
||||
|
||||
$href = $I->grabAttributeFrom('//a[text()="sending method settings"]', 'href');
|
||||
expect($href)->endsWith('page=mailpoet-settings#mta');
|
||||
|
||||
$I->click('Resume sending');
|
||||
$I->waitForText('Sending has been resumed.');
|
||||
}
|
||||
|
||||
function phpMailErrorNotice(\AcceptanceTester $I) {
|
||||
$I->wantTo('See proper sending error when sending failed with PHPMail');
|
||||
$I->login();
|
||||
|
||||
$errorMessage = 'Could not instantiate mail function. Unprocessed subscriber: (test <test@test.test>)';
|
||||
$settings = new Settings();
|
||||
$settings->withSendingMethod(Mailer::METHOD_PHPMAIL);
|
||||
$settings->withSendingError($errorMessage);
|
||||
|
||||
$I->amOnMailpoetPage('Emails');
|
||||
$I->waitForElement('.mailpoet_notice.notice-error div');
|
||||
$I->see('Sending has been paused due to a technical issue with PHPMail: ' . $errorMessage, '.notice-error p');
|
||||
$I->see('Please check your sending method configuration, you may need to consult with your hosting company.', '.notice-error p');
|
||||
$I->see('The easy alternative is to send emails with MailPoet Sending Service instead, like thousand of other users do.', '.notice-error p');
|
||||
$I->see('Sign up for free in minutes', '.notice-error p');
|
||||
$I->see('Resume sending', '.notice-error p');
|
||||
|
||||
$I->seeElement('a', [
|
||||
'text' => 'Sign up for free in minutes',
|
||||
'href' => 'https://www.mailpoet.com/free-plan/?utm_source=plugin&utm_campaign=sending-error',
|
||||
'target' => '_blank',
|
||||
]);
|
||||
|
||||
$I->click('Resume sending');
|
||||
$I->waitForText('Sending has been resumed.');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user