Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
bug #33210 [Mailer] Don't duplicate addresses in Sendgrid Transport (…
…pierredup) This PR was merged into the 4.3 branch. Discussion ---------- [Mailer] Don't duplicate addresses in Sendgrid Transport | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #33135 | License | MIT | Doc PR | N/A Sendgrid requires the `to`, `cc` and `bcc` fields to be unique Commits ------- 2706a97 Don't duplicate addresses in Sendgrid Transport
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Http/Api/SendgridTransportTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mailer\Bridge\Sendgrid\Tests\Http\Api; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mailer\Bridge\Sendgrid\Http\Api\SendgridTransport; | ||
use Symfony\Component\Mime\Email; | ||
use Symfony\Contracts\HttpClient\HttpClientInterface; | ||
use Symfony\Contracts\HttpClient\ResponseInterface; | ||
|
||
class SendgridTransportTest extends TestCase | ||
{ | ||
public function testSend() | ||
{ | ||
$email = new Email(); | ||
$email->from('foo@example.com') | ||
->to('bar@example.com') | ||
->bcc('baz@example.com'); | ||
|
||
$response = $this->createMock(ResponseInterface::class); | ||
|
||
$response | ||
->expects($this->once()) | ||
->method('getStatusCode') | ||
->willReturn(202); | ||
|
||
$httpClient = $this->createMock(HttpClientInterface::class); | ||
|
||
$httpClient | ||
->expects($this->once()) | ||
->method('request') | ||
->with('POST', 'https://api.sendgrid.com/v3/mail/send', [ | ||
'json' => [ | ||
'personalizations' => [ | ||
[ | ||
'to' => [['email' => 'bar@example.com']], | ||
'subject' => null, | ||
'bcc' => [['email' => 'baz@example.com']], | ||
], | ||
], | ||
'from' => ['email' => 'foo@example.com'], | ||
'content' => [], | ||
], | ||
'auth_bearer' => 'foo', | ||
]) | ||
->willReturn($response); | ||
|
||
$mailer = new SendgridTransport('foo', $httpClient); | ||
|
||
$mailer->send($email); | ||
} | ||
} |