Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4: (43 commits)
  [AssetMapper] Fix entrypoint scripts are not preloaded
  Fix typo in method resolvePackages
  Make FormPerformanceTestCase compatible with PHPUnit 10
  Avoid calling getInvocationCount()
  [AssetMapper] Always downloading vendor files
  [Security] Fix resetting traceable listeners
  [HttpClient] Fix type error with http_version 1.1
  [DependencyInjection] Add tests for `AutowireLocator`/`AutowireIterator`
  [DependencyInjection] Add `#[AutowireIterator]` attribute and improve `#[AutowireLocator]`
  Update documentation link
  Fix typo that causes unit test to fail
  Fix CS
  [AssetMapper] Add audit command
  [Mailer] Use idn encoded address otherwise Brevo throws an error
  [Messenger] Resend failed retries back to failure transport
  [FrameworkBundle] Fix call to invalid method in NotificationAssertionsTrait
  [Validator] Add missing italian translations
  [Notifier] Fix failing testcase
  Fix order array sum normalizedData and nestedData
  Add test for 0 and '0' in PeriodicalTrigger Fix '0' case error and remove duplicate code
  ...
  • Loading branch information
derrabus committed Oct 7, 2023
2 parents c044454 + e8d52e1 commit 3f76e5c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Tests/Transport/MailgunApiTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function testCustomHeader()
$deliveryTime = (new \DateTimeImmutable('2020-03-20 13:01:00'))->format(\DateTimeInterface::RFC2822);

$email = new Email();
$envelope = new Envelope(new Address('alice@system.com'), [new Address('bob@system.com')]);
$email->getHeaders()->addTextHeader('h:sender', $envelope->getSender()->toString());
$email->getHeaders()->addTextHeader('h:X-Mailgun-Variables', $json);
$email->getHeaders()->addTextHeader('h:foo', 'foo-value');
$email->getHeaders()->addTextHeader('t:text', 'text-value');
Expand All @@ -69,7 +71,6 @@ public function testCustomHeader()
$email->getHeaders()->addTextHeader('template', 'template-value');
$email->getHeaders()->addTextHeader('recipient-variables', 'recipient-variables-value');
$email->getHeaders()->addTextHeader('amp-html', 'amp-html-value');
$envelope = new Envelope(new Address('alice@system.com'), [new Address('bob@system.com')]);

$transport = new MailgunApiTransport('ACCESS_KEY', 'DOMAIN');
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
Expand All @@ -78,6 +79,8 @@ public function testCustomHeader()
$this->assertArrayHasKey('h:X-Mailgun-Variables', $payload);
$this->assertEquals($json, $payload['h:X-Mailgun-Variables']);

$this->assertArrayHasKey('h:sender', $payload);
$this->assertEquals($envelope->getSender()->toString(), $payload['h:sender']);
$this->assertArrayHasKey('h:foo', $payload);
$this->assertEquals('foo-value', $payload['h:foo']);
$this->assertArrayHasKey('t:text', $payload);
Expand Down
12 changes: 10 additions & 2 deletions Tests/Transport/MailgunHttpTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function testSend()
$this->assertStringContainsString('Subject: Hello!', $content);
$this->assertStringContainsString('To: Saif Eddin <saif.gmati@symfony.com>', $content);
$this->assertStringContainsString('From: Fabien <fabpot@symfony.com>', $content);
$this->assertStringContainsString('Sender: Senior Fabien Eddin <fabpot@symfony.com>', $content);
$this->assertStringContainsString('h:sender: "Senior Fabien Eddin" <fabpot@symfony.com>', $content);
$this->assertStringContainsString('Hello There!', $content);

return new MockResponse(json_encode(['id' => 'foobar']), [
Expand All @@ -79,11 +81,17 @@ public function testSend()
$transport->setPort(8984);

$mail = new Email();
$toAddress = new Address('saif.gmati@symfony.com', 'Saif Eddin');
$fromAddress = new Address('fabpot@symfony.com', 'Fabien');
$senderAddress = new Address('fabpot@symfony.com', 'Senior Fabien Eddin');
$mail->subject('Hello!')
->to(new Address('saif.gmati@symfony.com', 'Saif Eddin'))
->from(new Address('fabpot@symfony.com', 'Fabien'))
->to($toAddress)
->from($fromAddress)
->sender($senderAddress)
->text('Hello There!');

$mail->getHeaders()->addHeader('h:sender', $mail->getSender()->toString());

$message = $transport->send($mail);

$this->assertSame('foobar', $message->getMessageId());
Expand Down
1 change: 1 addition & 0 deletions Transport/MailgunApiTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
private function getPayload(Email $email, Envelope $envelope): array
{
$headers = $email->getHeaders();
$headers->addHeader('h:sender', $envelope->getSender()->toString());
$html = $email->getHtmlBody();
if (null !== $html && \is_resource($html)) {
if (stream_get_meta_data($html)['seekable'] ?? false) {
Expand Down
1 change: 1 addition & 0 deletions Transport/MailgunHttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function __toString(): string
protected function doSendHttp(SentMessage $message): ResponseInterface
{
$body = new FormDataPart([
'h:sender' => $message->getEnvelope()->getSender()->toString(),
'to' => implode(',', $this->stringifyAddresses($message->getEnvelope()->getRecipients())),
'message' => new DataPart($message->toString(), 'message.mime'),
]);
Expand Down

0 comments on commit 3f76e5c

Please sign in to comment.