Skip to content

Commit

Permalink
bug #37159 [Mailer] Fixed generator bug when creating multiple transp…
Browse files Browse the repository at this point in the history
…orts using Transport::fromDsn (atailouloute)

This PR was submitted for the master branch but it was merged into the 4.4 branch instead.

Discussion
----------

[Mailer] Fixed generator bug when creating multiple transports using Transport::fromDsn

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |  #37158
| License       | MIT
| Doc PR        | N/A

Commits
-------

c5833fa [Mailer] Fixed generator bug when creating multiple transports using Transport::fromDsn
  • Loading branch information
fabpot committed Jun 9, 2020
2 parents 017af04 + c5833fa commit 9b132bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/Symfony/Component/Mailer/Tests/TransportTest.php
Expand Up @@ -60,6 +60,22 @@ public function fromStringProvider(): iterable
];
}

/**
* @dataProvider fromDsnProvider
*/
public function testFromDsn(string $dsn, TransportInterface $transport): void
{
$this->assertEquals($transport, Transport::fromDsn($dsn));
}

public function fromDsnProvider(): iterable
{
yield 'multiple transports' => [
'failover(smtp://a smtp://b)',
new FailoverTransport([new Transport\Smtp\EsmtpTransport('a'), new Transport\Smtp\EsmtpTransport('b')]),
];
}

/**
* @dataProvider fromWrongStringProvider
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mailer/Transport.php
Expand Up @@ -51,7 +51,7 @@ class Transport

public static function fromDsn(string $dsn, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null): TransportInterface
{
$factory = new self(self::getDefaultFactories($dispatcher, $client, $logger));
$factory = new self(iterator_to_array(self::getDefaultFactories($dispatcher, $client, $logger)));

return $factory->fromString($dsn);
}
Expand Down

0 comments on commit 9b132bc

Please sign in to comment.