Fix tests after last changes

[MAILPOET-4639]
This commit is contained in:
Jan Lysý
2023-01-06 20:04:09 +01:00
committed by Aschepikov
parent c79787c677
commit 2e97cb6924
3 changed files with 12 additions and 7 deletions

View File

@ -76,7 +76,7 @@ class MailPoetMapper {
$resultParsed = json_decode($result['message'], true);
$message = __('Error while sending.', 'mailpoet');
if (!is_array($resultParsed)) {
if ($result['error'] === API::ERROR_MESSAGE_DMRAC) {
if (isset($result['error']) && $result['error'] === API::ERROR_MESSAGE_DMRAC) {
$message .= $this->getDmarcMessage($result, $sender);
} else {
$message .= ' ' . $result['message'];

View File

@ -304,7 +304,8 @@ class MailPoetAPITest extends \MailPoetTest {
['sendMessages' => [
'code' => API::RESPONSE_CODE_CAN_NOT_SEND,
'status' => API::SENDING_STATUS_SEND_ERROR,
'message' => MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED,
'message' => API::ERROR_MESSAGE_INVALID_FROM,
'error' => API::ERROR_MESSAGE_INVALID_FROM,
]]
);
$mailer->send([$this->newsletter], [$this->subscriber]);

View File

@ -74,7 +74,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
$apiResult = [
'code' => API::RESPONSE_CODE_CAN_NOT_SEND,
'status' => API::SENDING_STATUS_SEND_ERROR,
'message' => MailerError::MESSAGE_EMAIL_FORBIDDEN_ACTION,
'message' => API::ERROR_MESSAGE_BANNED,
'error' => API::ERROR_MESSAGE_BANNED,
];
$error = $this->mapper->getErrorForResult($apiResult, $this->subscribers);
@ -88,7 +89,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
$apiResult = [
'code' => API::RESPONSE_CODE_CAN_NOT_SEND,
'status' => API::SENDING_STATUS_SEND_ERROR,
'message' => MailerError::MESSAGE_EMAIL_INSUFFICIENT_PRIVILEGES,
'message' => API::ERROR_MESSAGE_INSUFFICIENT_PRIVILEGES,
'error' => API::ERROR_MESSAGE_INSUFFICIENT_PRIVILEGES,
];
$error = $this->mapper->getErrorForResult($apiResult, $this->subscribers);
@ -102,7 +104,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
$apiResult = [
'code' => API::RESPONSE_CODE_CAN_NOT_SEND,
'status' => API::SENDING_STATUS_SEND_ERROR,
'message' => MailerError::MESSAGE_EMAIL_NOT_AUTHORIZED,
'message' => API::ERROR_MESSAGE_INVALID_FROM,
'error' => API::ERROR_MESSAGE_INVALID_FROM,
];
$error = $this->mapper->getErrorForResult($apiResult, $this->subscribers);
@ -174,7 +177,8 @@ class MailPoetMapperTest extends \MailPoetUnitTest {
$apiResult = [
'code' => API::RESPONSE_CODE_CAN_NOT_SEND,
'status' => API::SENDING_STATUS_SEND_ERROR,
'message' => MailerError::MESSAGE_PENDING_APPROVAL,
'message' => API::ERROR_MESSAGE_PENDING_APPROVAL,
'error' => API::ERROR_MESSAGE_PENDING_APPROVAL,
];
$error = $this->mapper->getErrorForResult($apiResult, $this->subscribers);
expect($error)->isInstanceOf(MailerError::class);