Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab48b7b

Browse files
minor #40006 [Mailer] Fix SES test (jderusse)
This PR was merged into the 5.2 branch. Discussion ---------- [Mailer] Fix SES test | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - When using the native (deprecated) Transport, we used the `SES` AWS endoint, but the new version that rely on async-aws uses `SESV2`. The former uses XML, but the new one use JSON. Since async-aws/aws#933 `async-aws` is stricter on reponses parsing, and now is not able to parse an XML response when the endpoint expect JSON. This PR fixes the tests to be compliant with AWS SESV2 protocol Commits ------- 2176ff6 Fix SES test
2 parents 8449d8a + 2176ff6 commit ab48b7b

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiAsyncAwsTransportTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,16 @@ public function testSend()
100100
public function testSendThrowsForErrorResponse()
101101
{
102102
$client = new MockHttpClient(function (string $method, string $url, array $options): ResponseInterface {
103-
$xml = "<SendEmailResponse xmlns=\"https://email.amazonaws.com/doc/2010-03-31/\">
104-
<Error>
105-
<Message>i'm a teapot</Message>
106-
<Code>418</Code>
107-
</Error>
108-
</SendEmailResponse>";
109-
110-
return new MockResponse($xml, [
103+
$json = json_encode([
104+
'message' => 'i\'m a teapot',
105+
'type' => 'sender',
106+
]);
107+
108+
return new MockResponse($json, [
111109
'http_code' => 418,
110+
'response_headers' => [
111+
'x-amzn-errortype' => '418',
112+
],
112113
]);
113114
});
114115

src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpAsyncAwsTransportTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ public function testSend()
9595
public function testSendThrowsForErrorResponse()
9696
{
9797
$client = new MockHttpClient(function (string $method, string $url, array $options): ResponseInterface {
98-
$xml = "<SendEmailResponse xmlns=\"https://email.amazonaws.com/doc/2010-03-31/\">
99-
<Error>
100-
<Message>i'm a teapot</Message>
101-
<Code>418</Code>
102-
</Error>
103-
</SendEmailResponse>";
104-
105-
return new MockResponse($xml, [
98+
$json = json_encode([
99+
'message' => 'i\'m a teapot',
100+
'type' => 'sender',
101+
]);
102+
103+
return new MockResponse($json, [
106104
'http_code' => 418,
105+
'response_headers' => [
106+
'x-amzn-errortype' => '418',
107+
],
107108
]);
108109
});
109110

0 commit comments

Comments
 (0)