Skip to content

Commit abb4d43

Browse files
Merge branch '4.3' into 4.4
* 4.3: [Routing] Add a param annotation for $annot. [DI] fix docblock [Console] fix docblock Add missing translations for Armenian locale [Process] Added missing return type. [Process] Doc block backport. Added doc block for Registry::supports(). [Cache] Fix predis test Don't duplicate addresses in Sendgrid Transport Remove unnecessary statement Fix some docblocks. [Messenger] make delay exchange and queues durable like the normal ones by default Cancel delayed message if handler fails Added tests for #32370
2 parents 7d60857 + 7ca45f1 commit abb4d43

File tree

6 files changed

+246
-2
lines changed

6 files changed

+246
-2
lines changed

Api/SendgridTransportTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Mailer\Bridge\Sendgrid\Tests\Http\Api;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mailer\Bridge\Sendgrid\Http\Api\SendgridTransport;
16+
use Symfony\Component\Mime\Email;
17+
use Symfony\Contracts\HttpClient\HttpClientInterface;
18+
use Symfony\Contracts\HttpClient\ResponseInterface;
19+
20+
class SendgridTransportTest extends TestCase
21+
{
22+
public function testSend()
23+
{
24+
$email = new Email();
25+
$email->from('[email protected]')
26+
27+
28+
29+
$response = $this->createMock(ResponseInterface::class);
30+
31+
$response
32+
->expects($this->once())
33+
->method('getStatusCode')
34+
->willReturn(202);
35+
36+
$httpClient = $this->createMock(HttpClientInterface::class);
37+
38+
$httpClient
39+
->expects($this->once())
40+
->method('request')
41+
->with('POST', 'https://api.sendgrid.com/v3/mail/send', [
42+
'json' => [
43+
'personalizations' => [
44+
[
45+
'to' => [['email' => '[email protected]']],
46+
'subject' => null,
47+
'bcc' => [['email' => '[email protected]']],
48+
],
49+
],
50+
'from' => ['email' => '[email protected]'],
51+
'content' => [],
52+
],
53+
'auth_bearer' => 'foo',
54+
])
55+
->willReturn($response);
56+
57+
$mailer = new SendgridTransport('foo', $httpClient);
58+
59+
$mailer->send($email);
60+
}
61+
}

Http/Api/SendgridTransportTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Mailer\Bridge\Sendgrid\Tests\Http\Api;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mailer\Bridge\Sendgrid\Http\Api\SendgridTransport;
16+
use Symfony\Component\Mime\Email;
17+
use Symfony\Contracts\HttpClient\HttpClientInterface;
18+
use Symfony\Contracts\HttpClient\ResponseInterface;
19+
20+
class SendgridTransportTest extends TestCase
21+
{
22+
public function testSend()
23+
{
24+
$email = new Email();
25+
$email->from('[email protected]')
26+
27+
28+
29+
$response = $this->createMock(ResponseInterface::class);
30+
31+
$response
32+
->expects($this->once())
33+
->method('getStatusCode')
34+
->willReturn(202);
35+
36+
$httpClient = $this->createMock(HttpClientInterface::class);
37+
38+
$httpClient
39+
->expects($this->once())
40+
->method('request')
41+
->with('POST', 'https://api.sendgrid.com/v3/mail/send', [
42+
'json' => [
43+
'personalizations' => [
44+
[
45+
'to' => [['email' => '[email protected]']],
46+
'subject' => null,
47+
'bcc' => [['email' => '[email protected]']],
48+
],
49+
],
50+
'from' => ['email' => '[email protected]'],
51+
'content' => [],
52+
],
53+
'auth_bearer' => 'foo',
54+
])
55+
->willReturn($response);
56+
57+
$mailer = new SendgridTransport('foo', $httpClient);
58+
59+
$mailer->send($email);
60+
}
61+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Mailer\Bridge\Sendgrid\Tests\Http\Api;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mailer\Bridge\Sendgrid\Http\Api\SendgridTransport;
16+
use Symfony\Component\Mime\Email;
17+
use Symfony\Contracts\HttpClient\HttpClientInterface;
18+
use Symfony\Contracts\HttpClient\ResponseInterface;
19+
20+
class SendgridTransportTest extends TestCase
21+
{
22+
public function testSend()
23+
{
24+
$email = new Email();
25+
$email->from('[email protected]')
26+
27+
28+
29+
$response = $this->createMock(ResponseInterface::class);
30+
31+
$response
32+
->expects($this->once())
33+
->method('getStatusCode')
34+
->willReturn(202);
35+
36+
$httpClient = $this->createMock(HttpClientInterface::class);
37+
38+
$httpClient
39+
->expects($this->once())
40+
->method('request')
41+
->with('POST', 'https://api.sendgrid.com/v3/mail/send', [
42+
'json' => [
43+
'personalizations' => [
44+
[
45+
'to' => [['email' => '[email protected]']],
46+
'subject' => null,
47+
'bcc' => [['email' => '[email protected]']],
48+
],
49+
],
50+
'from' => ['email' => '[email protected]'],
51+
'content' => [],
52+
],
53+
'auth_bearer' => 'foo',
54+
])
55+
->willReturn($response);
56+
57+
$mailer = new SendgridTransport('foo', $httpClient);
58+
59+
$mailer->send($email);
60+
}
61+
}

Sendgrid/Transport/SendgridApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private function getPayload(Email $email, SmtpEnvelope $envelope): array
7373
}
7474

7575
$personalization = [
76-
'to' => array_map($addressStringifier, $this->getRecipients($email, $envelope)),
76+
'to' => array_map($addressStringifier, $email->getTo()),
7777
'subject' => $email->getSubject(),
7878
];
7979
if ($emails = array_map($addressStringifier, $email->getCc())) {

SendgridApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private function getPayload(Email $email, SmtpEnvelope $envelope): array
7373
}
7474

7575
$personalization = [
76-
'to' => array_map($addressStringifier, $this->getRecipients($email, $envelope)),
76+
'to' => array_map($addressStringifier, $email->getTo()),
7777
'subject' => $email->getSubject(),
7878
];
7979
if ($emails = array_map($addressStringifier, $email->getCc())) {

SendgridTransportTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Mailer\Bridge\Sendgrid\Tests\Http\Api;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mailer\Bridge\Sendgrid\Http\Api\SendgridTransport;
16+
use Symfony\Component\Mime\Email;
17+
use Symfony\Contracts\HttpClient\HttpClientInterface;
18+
use Symfony\Contracts\HttpClient\ResponseInterface;
19+
20+
class SendgridTransportTest extends TestCase
21+
{
22+
public function testSend()
23+
{
24+
$email = new Email();
25+
$email->from('[email protected]')
26+
27+
28+
29+
$response = $this->createMock(ResponseInterface::class);
30+
31+
$response
32+
->expects($this->once())
33+
->method('getStatusCode')
34+
->willReturn(202);
35+
36+
$httpClient = $this->createMock(HttpClientInterface::class);
37+
38+
$httpClient
39+
->expects($this->once())
40+
->method('request')
41+
->with('POST', 'https://api.sendgrid.com/v3/mail/send', [
42+
'json' => [
43+
'personalizations' => [
44+
[
45+
'to' => [['email' => '[email protected]']],
46+
'subject' => null,
47+
'bcc' => [['email' => '[email protected]']],
48+
],
49+
],
50+
'from' => ['email' => '[email protected]'],
51+
'content' => [],
52+
],
53+
'auth_bearer' => 'foo',
54+
])
55+
->willReturn($response);
56+
57+
$mailer = new SendgridTransport('foo', $httpClient);
58+
59+
$mailer->send($email);
60+
}
61+
}

0 commit comments

Comments
 (0)