Add soft level errors distinction for PHPMail method

[MAILPOET-1154]
This commit is contained in:
Rostislav Wolny
2018-09-11 14:55:39 +02:00
parent 45433c9deb
commit fe69b56692
3 changed files with 45 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace MailPoet\Test\Mailer\Methods\ErrorMappers;
use MailPoet\Mailer\MailerError;
use MailPoet\Mailer\Methods\ErrorMappers\PHPMailMapper;
class PHPMailMapperTest extends \MailPoetTest {
/** @var PHPMailMapper*/
private $mapper;
function _before() {
$this->mapper = new PHPMailMapper();
}
function testGetProperErrorForSubscriber() {
$error = $this->mapper->getErrorForSubscriber('john@rambo.com', []);
expect($error->getLevel())->equals(MailerError::LEVEL_HARD);
expect($error->getMessage())->equals('PHPMail has returned an unknown error.');
expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com');
}
function testGetProperErrorFromException() {
$error = $this->mapper->getErrorFromException(new \Exception('Some message'), 'john@rambo.com', []);
expect($error->getLevel())->equals(MailerError::LEVEL_HARD);
expect($error->getMessage())->equals('Some message');
expect($error->getSubscriberErrors()[0]->getEmail())->equals('john@rambo.com');
}
function testGetSoftErrorFromExceptionForInvalidEmail() {
$error = $this->mapper->getErrorFromException(new \Exception('Invalid address. (Add ...'), 'john@rambo.com', []);
expect($error->getLevel())->equals(MailerError::LEVEL_SOFT);
}
}