|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Symfony\Component\Mailer\Bridge\Mailgun\Tests\Factory; |
| 4 | + |
| 5 | +use PHPUnit\Framework\TestCase; |
| 6 | +use Symfony\Component\Mailer\Bridge\Mailgun; |
| 7 | +use Symfony\Component\Mailer\Bridge\Mailgun\Factory\MailgunTransportFactory; |
| 8 | +use Symfony\Component\Mailer\Tests\TransportFactoryTestCase; |
| 9 | +use Symfony\Component\Mailer\Transport\Dsn; |
| 10 | +use Symfony\Component\Mailer\Transport\TransportFactoryInterface; |
| 11 | + |
| 12 | +class MailgunTransportFactoryTest extends TransportFactoryTestCase |
| 13 | +{ |
| 14 | + public function getFactory(): TransportFactoryInterface |
| 15 | + { |
| 16 | + return new MailgunTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); |
| 17 | + } |
| 18 | + |
| 19 | + public function supportsProvider(): iterable |
| 20 | + { |
| 21 | + yield [ |
| 22 | + new Dsn('api', 'mailgun'), |
| 23 | + true, |
| 24 | + ]; |
| 25 | + |
| 26 | + yield [ |
| 27 | + new Dsn('http', 'mailgun'), |
| 28 | + true, |
| 29 | + ]; |
| 30 | + |
| 31 | + yield [ |
| 32 | + new Dsn('smtp', 'mailgun'), |
| 33 | + true, |
| 34 | + ]; |
| 35 | + |
| 36 | + yield [ |
| 37 | + new Dsn('smtp', 'example.com'), |
| 38 | + false, |
| 39 | + ]; |
| 40 | + } |
| 41 | + |
| 42 | + public function createProvider(): iterable |
| 43 | + { |
| 44 | + yield [ |
| 45 | + new Dsn('api', 'mailgun', self::USER, self::PASSWORD), |
| 46 | + new Mailgun\Http\Api\MailgunTransport(self::USER, self::PASSWORD, null, $this->getClient(), $this->getDispatcher(), $this->getLogger()), |
| 47 | + ]; |
| 48 | + |
| 49 | + yield [ |
| 50 | + new Dsn('api', 'mailgun', self::USER, self::PASSWORD, null, ['region' => 'eu']), |
| 51 | + new Mailgun\Http\Api\MailgunTransport(self::USER, self::PASSWORD, 'eu', $this->getClient(), $this->getDispatcher(), $this->getLogger()), |
| 52 | + ]; |
| 53 | + |
| 54 | + yield [ |
| 55 | + new Dsn('http', 'mailgun', self::USER, self::PASSWORD), |
| 56 | + new Mailgun\Http\MailgunTransport(self::USER, self::PASSWORD, null, $this->getClient(), $this->getDispatcher(), $this->getLogger()), |
| 57 | + ]; |
| 58 | + |
| 59 | + yield [ |
| 60 | + new Dsn('smtp', 'mailgun', self::USER, self::PASSWORD), |
| 61 | + new Mailgun\Smtp\MailgunTransport(self::USER, self::PASSWORD, null, $this->getDispatcher(), $this->getLogger()), |
| 62 | + ]; |
| 63 | + } |
| 64 | + |
| 65 | + public function unsupportedSchemeProvider(): iterable |
| 66 | + { |
| 67 | + yield [new Dsn('foo', 'mailgun', self::USER, self::PASSWORD)]; |
| 68 | + } |
| 69 | +} |
0 commit comments