Files
piratepoet/tests/unit/Mailer/Methods/ErrorMappers/AmazonSESMapperTest.php
Rostislav Wolny f5c9d0f7db Remove unnecessary test_email extra parameter for mailer->send
It was used only to prevent appending unprocessed subscribers into error message.
Since the message is now composed by on demand by MailerError the parameter is not needed any more.

[MAILPOET-1154]
2018-09-13 11:12:38 +02:00

57 lines
1.8 KiB
PHP

<?php
namespace MailPoet\Test\Mailer\Methods\ErrorMappers;
use MailPoet\Mailer\MailerError;
use MailPoet\Mailer\Methods\ErrorMappers\AmazonSESMapper;
use SimpleXMLElement;
class AmazonSESMapperTest extends \MailPoetTest {
/** @var AmazonSESMapper*/
private $mapper;
/** @var array */
private $response_data = [];
function _before() {
$this->mapper = new AmazonSESMapper();
$this->response_data = [
'Error' => [
'Type' => 'Sender',
'Code' => 'ConfigurationSetDoesNotExist',
'Message' => 'Some message',
],
'RequestId' => '01ca93ec-b5a3-11e8-bff8-49dd5ddf8019',
];
}
function testGetProperError() {
$response = $this->buildXmlResponseFromArray($this->response_data, new SimpleXMLElement('<response/>'));
$error = $this->mapper->getErrorFromResponse($response, '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 testGetSoftErrorForRejectedMessage() {
$this->response_data['Error']['Code'] = 'MessageRejected';
$response = $this->buildXmlResponseFromArray($this->response_data, new SimpleXMLElement('<response/>'));
$error = $this->mapper->getErrorFromResponse($response, 'john@rambo.com');
expect($error->getLevel())->equals(MailerError::LEVEL_SOFT);
}
/**
* @return SimpleXMLElement
*/
private function buildXmlResponseFromArray($response_data, SimpleXMLElement $xml) {
foreach($response_data as $tag => $value) {
if(is_array($value)) {
$this->buildXmlResponseFromArray($value, $xml->addChild($tag));
} else {
$xml->addChild($tag, $value);
}
}
return $xml;
}
}