|
11 | 11 |
|
12 | 12 | namespace Symfony\Component\Notifier\Bridge\Esendex\Tests;
|
13 | 13 |
|
14 |
| -use PHPUnit\Framework\TestCase; |
15 | 14 | use Symfony\Component\Notifier\Bridge\Esendex\EsendexTransportFactory;
|
16 |
| -use Symfony\Component\Notifier\Exception\IncompleteDsnException; |
17 |
| -use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; |
18 |
| -use Symfony\Component\Notifier\Transport\Dsn; |
| 15 | +use Symfony\Component\Notifier\Tests\TransportFactoryTestCase; |
| 16 | +use Symfony\Component\Notifier\Transport\TransportFactoryInterface; |
19 | 17 |
|
20 |
| -final class EsendexTransportFactoryTest extends TestCase |
| 18 | +final class EsendexTransportFactoryTest extends TransportFactoryTestCase |
21 | 19 | {
|
22 |
| - public function testCreateWithDsn() |
| 20 | + /** |
| 21 | + * @return EsendexTransportFactory |
| 22 | + */ |
| 23 | + public function createFactory(): TransportFactoryInterface |
23 | 24 | {
|
24 |
| - $factory = $this->createFactory(); |
25 |
| - |
26 |
| - $transport = $factory->create(Dsn::fromString('esendex://email:password@host.test?accountreference=testAccountreference&from=testFrom')); |
27 |
| - |
28 |
| - $this->assertSame('esendex://host.test', (string) $transport); |
29 |
| - } |
30 |
| - |
31 |
| - public function testCreateWithMissingOptionAccountreferenceThrowsIncompleteDsnException() |
32 |
| - { |
33 |
| - $factory = $this->createFactory(); |
34 |
| - |
35 |
| - $this->expectException(IncompleteDsnException::class); |
36 |
| - |
37 |
| - $factory->create(Dsn::fromString('esendex://email:password@host?from=FROM')); |
38 |
| - } |
39 |
| - |
40 |
| - public function testCreateWithMissingOptionFromThrowsIncompleteDsnException() |
41 |
| - { |
42 |
| - $factory = $this->createFactory(); |
43 |
| - |
44 |
| - $this->expectException(IncompleteDsnException::class); |
45 |
| - |
46 |
| - $factory->create(Dsn::fromString('esendex://email:password@host?accountreference=ACCOUNTREFERENCE')); |
| 25 | + return new EsendexTransportFactory(); |
47 | 26 | }
|
48 | 27 |
|
49 |
| - public function testSupportsReturnsTrueWithSupportedScheme() |
| 28 | + public function createProvider(): iterable |
50 | 29 | {
|
51 |
| - $factory = $this->createFactory(); |
52 |
| - |
53 |
| - $this->assertTrue($factory->supports(Dsn::fromString('esendex://email:password@host?accountreference=ACCOUNTREFERENCE&from=FROM'))); |
| 30 | + yield [ |
| 31 | + 'esendex://host.test?accountreference=ACCOUNTREFERENCE&from=FROM', |
| 32 | + 'esendex://email:password@host.test?accountreference=ACCOUNTREFERENCE&from=FROM', |
| 33 | + ]; |
54 | 34 | }
|
55 | 35 |
|
56 |
| - public function testSupportsReturnsFalseWithUnsupportedScheme() |
| 36 | + public function supportsProvider(): iterable |
57 | 37 | {
|
58 |
| - $factory = $this->createFactory(); |
59 |
| - |
60 |
| - $this->assertFalse($factory->supports(Dsn::fromString('somethingElse://email:password@host?accountreference=ACCOUNTREFERENCE&from=FROM'))); |
| 38 | + yield [true, 'esendex://email:password@host?accountreference=ACCOUNTREFERENCE&from=FROM']; |
| 39 | + yield [false, 'somethingElse://email:password@default']; |
61 | 40 | }
|
62 | 41 |
|
63 |
| - public function testUnsupportedSchemeThrowsUnsupportedSchemeException() |
| 42 | + public function incompleteDsnProvider(): iterable |
64 | 43 | {
|
65 |
| - $factory = $this->createFactory(); |
66 |
| - |
67 |
| - $this->expectException(UnsupportedSchemeException::class); |
68 |
| - $factory->create(Dsn::fromString('somethingElse://email:password@host?accountreference=REFERENCE&from=FROM')); |
| 44 | + yield 'missing option: from' => ['esendex://email:password@host?accountreference=ACCOUNTREFERENCE']; |
| 45 | + yield 'missing option: accountreference' => ['esendex://email:password@host?from=FROM']; |
69 | 46 | }
|
70 | 47 |
|
71 |
| - public function testUnsupportedSchemeThrowsUnsupportedSchemeExceptionEvenIfRequiredOptionIsMissing() |
| 48 | + public function unsupportedSchemeProvider(): iterable |
72 | 49 | {
|
73 |
| - $factory = $this->createFactory(); |
74 |
| - |
75 |
| - $this->expectException(UnsupportedSchemeException::class); |
76 |
| - |
77 |
| - // unsupported scheme and missing "from" option |
78 |
| - $factory->create(Dsn::fromString('somethingElse://email:password@host?accountreference=REFERENCE')); |
79 |
| - } |
80 |
| - |
81 |
| - private function createFactory(): EsendexTransportFactory |
82 |
| - { |
83 |
| - return new EsendexTransportFactory(); |
| 50 | + yield ['somethingElse://email:password@default?accountreference=ACCOUNTREFERENCE&from=FROM']; |
| 51 | + yield ['somethingElse://email:password@host?accountreference=ACCOUNTREFERENCE']; // missing "from" option |
84 | 52 | }
|
85 | 53 | }
|
0 commit comments