|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 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\Infobip\Tests\Transport; |
| 13 | + |
| 14 | +use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipApiTransport; |
| 15 | +use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipSmtpTransport; |
| 16 | +use Symfony\Component\Mailer\Bridge\Infobip\Transport\InfobipTransportFactory; |
| 17 | +use Symfony\Component\Mailer\Test\TransportFactoryTestCase; |
| 18 | +use Symfony\Component\Mailer\Transport\Dsn; |
<
67DE
code> | 19 | +use Symfony\Component\Mailer\Transport\TransportFactoryInterface; |
| 20 | + |
| 21 | +class InfobipApiTransportFactoryTest extends TransportFactoryTestCase |
| 22 | +{ |
| 23 | + public function getFactory(): TransportFactoryInterface |
| 24 | + { |
| 25 | + return new InfobipTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); |
| 26 | + } |
| 27 | + |
| 28 | + public function supportsProvider(): iterable |
| 29 | + { |
| 30 | + yield [ |
| 31 | + new Dsn('infobip+api', 'default'), |
| 32 | + true, |
| 33 | + ]; |
| 34 | + |
| 35 | + yield [ |
| 36 | + new Dsn('infobip', 'default'), |
| 37 | + true, |
| 38 | + ]; |
| 39 | + |
| 40 | + yield [ |
| 41 | + new Dsn('infobip+smtp', 'default'), |
| 42 | + true, |
| 43 | + ]; |
| 44 | + |
| 45 | + yield [ |
| 46 | + new Dsn('infobip+smtps', 'default'), |
| 47 | + true, |
| 48 | + ]; |
| 49 | + |
| 50 | + yield [ |
| 51 | + new Dsn('infobip+smtp', 'example.com'), |
| 52 | + true, |
| 53 | + ]; |
| 54 | + } |
| 55 | + |
| 56 | + public function createProvider(): iterable |
| 57 | + { |
| 58 | + $dispatcher = $this->getDispatcher(); |
| 59 | + $logger = $this->getLogger(); |
| 60 | + |
| 61 | + yield [ |
| 62 | + new Dsn('infobip+api', 'example.com', self::PASSWORD), |
| 63 | + (new InfobipApiTransport(self::PASSWORD, $this->getClient(), $dispatcher, $logger))->setHost('example.com'), |
| 64 | + ]; |
| 65 | + |
| 66 | + yield [ |
| 67 | + new Dsn('infobip', 'default', self::PASSWORD), |
| 68 | + new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger), |
| 69 | + ]; |
| 70 | + |
| 71 | + yield [ |
| 72 | + new Dsn('infobip+smtp', 'default', self::PASSWORD), |
| 73 | + new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger), |
| 74 | + ]; |
| 75 | + |
| 76 | + yield [ |
| 77 | + new Dsn('infobip+smtps', 'default', self::PASSWORD), |
| 78 | + new InfobipSmtpTransport(self::PASSWORD, $dispatcher, $logger), |
| 79 | + ]; |
| 80 | + } |
| 81 | + |
| 82 | + public function unsupportedSchemeProvider(): iterable |
| 83 | + { |
| 84 | + yield [ |
| 85 | + new Dsn('infobip+foo', 'infobip', self::USER, self::PASSWORD), |
| 86 | + 'The "infobip+foo" scheme is not supported; supported schemes for mailer "infobip" are: "infobip", "infobip+api", "infobip+smtp", "infobip+smtps".', |
| 87 | + ]; |
| 88 | + } |
| 89 | + |
| 90 | + public function incompleteDsnProvider(): iterable |
| 91 | + { |
| 92 | + yield [new Dsn('infobip+smtp', 'default')]; |
| 93 | + yield [new Dsn('infobip+api', 'default')]; |
| 94 | + yield [new Dsn('infobip+api', 'default', self::PASSWORD)]; |
| 95 | + } |
| 96 | +} |
0 commit comments