bug #33429 [Mailer] hotfix (fabpot)
This PR was merged into the 4.4 branch.
Discussion
----------
[Mailer] hotfix
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.
Additionally (see https://symfony.com/roadmap):
- Bug fixes must be submitted against the lowest maintained branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against branch 4.4.
- Legacy code removals go to the master branch.
-->
Commits
-------
e15df84313
[Mailer] fixed wrong behavior
This commit is contained in:
commit
85d0982f84
@ -0,0 +1,51 @@
|
||||
<?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\Tests\Transport;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Mailer\Transport\TransportInterface;
|
||||
use Symfony\Component\Mailer\Transport\Transports;
|
||||
use Symfony\Component\Mime\Header\Headers;
|
||||
use Symfony\Component\Mime\Message;
|
||||
use Symfony\Component\Mime\Part\TextPart;
|
||||
|
||||
class TransportsTest extends TestCase
|
||||
{
|
||||
public function testDefaultTransport()
|
||||
{
|
||||
$transport = new Transports([
|
||||
'foo' => $foo = $this->createMock(TransportInterface::class),
|
||||
'bar' => $bar = $this->createMock(TransportInterface::class),
|
||||
]);
|
||||
|
||||
$foo->expects($this->once())->method('send');
|
||||
$bar->expects($this->never())->method('send');
|
||||
|
||||
$email = new Message(new Headers(), new TextPart('...'));
|
||||
$transport->send($email);
|
||||
}
|
||||
|
||||
public function testOverrideTransport()
|
||||
{
|
||||
$transport = new Transports([
|
||||
'foo' => $foo = $this->createMock(TransportInterface::class),
|
||||
'bar' => $bar = $this->createMock(TransportInterface::class),
|
||||
]);
|
||||
|
||||
$foo->expects($this->never())->method('send');
|
||||
$bar->expects($this->once())->method('send');
|
||||
|
||||
$headers = (new Headers())->addTextHeader('X-Transport', 'bar');
|
||||
$email = new Message($headers, new TextPart('...'));
|
||||
$transport->send($email);
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ class Transports implements TransportInterface
|
||||
}
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
$transport = $headers->get('X-Transport');
|
||||
$transport = $headers->get('X-Transport')->getBody();
|
||||
$headers->remove('X-Transport');
|
||||
|
||||
if (!isset($this->transports[$transport])) {
|
||||
|
Reference in New Issue
Block a user