Add soft level errors distinction for SMTP method

[MAILPOET-1154]
This commit is contained in:
Rostislav Wolny
2018-09-11 14:05:31 +02:00
parent 6437f4a1b3
commit 45433c9deb
3 changed files with 28 additions and 4 deletions

View File

@ -2,6 +2,7 @@
namespace MailPoet\Test\Mailer\Methods\ErrorMappers;
use MailPoet\Mailer\Mailer;
use MailPoet\Mailer\MailerError;
use MailPoet\Mailer\Methods\ErrorMappers\SMTPMapper;
class SMTPMapperTest extends \MailPoetTest {
@ -18,9 +19,17 @@ class SMTPMapperTest extends \MailPoetTest {
. 'Log data:' . PHP_EOL
. '++ Starting Swift_SmtpTransport' . PHP_EOL
. '!! Connection could not be established with host localhost [Connection refused #111] (code: 0)';
$error = $this->mapper->getErrorFromException(new \Exception($message));
$error = $this->mapper->getErrorFromException(new \Exception($message), 'john@rambo.com');
expect($error->getMessage())
->equals('Connection could not be established with host localhost [Connection refused #111]');
expect($error->getLevel())->equals(MailerError::LEVEL_HARD);
expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com');
}
function testItCreatesSoftErrorForInvalidEmail() {
$message = 'Invalid email';
$error = $this->mapper->getErrorFromException(new \Swift_RfcComplianceException($message), 'john@rambo.com');
expect($error->getLevel())->equals(MailerError::LEVEL_SOFT);
}
function testItCanProcessLogMessageWhenOneExists() {