Move current unit tests to integration tests

This commit is contained in:
wxa
2018-10-17 13:27:34 +03:00
parent b21ef30202
commit 87e515b89d
175 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<?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;
}
}