|
2 | 2 |
|
3 | 3 | namespace Symfony\Component\Notifier\Bridge\LinkedIn\Tests;
|
4 | 4 |
|
5 |
| -use PHPUnit\Framework\TestCase; |
6 | 5 | use Symfony\Component\Notifier\Bridge\LinkedIn\LinkedInTransportFactory;
|
7 |
| -use Symfony\Component\Notifier\Exception\IncompleteDsnException; |
8 |
| -use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; |
9 |
| -use Symfony\Component\Notifier\Transport\Dsn; |
| 6 | +use Symfony\Component\Notifier\Tests\TransportFactoryTestCase; |
| 7 | +use Symfony\Component\Notifier\Transport\TransportFactoryInterface; |
10 | 8 |
|
11 |
| -final class LinkedInTransportFactoryTest extends TestCase |
| 9 | +final class LinkedInTransportFactoryTest extends TransportFactoryTestCase |
12 | 10 | {
|
13 |
| - public function testCreateWithDsn() |
| 11 | + /** |
| 12 | + * @return LinkedInTransportFactory |
| 13 | + */ |
| 14 | + public function createFactory(): TransportFactoryInterface |
14 | 15 | {
|
15 |
| - $factory = $this->createFactory(); |
16 |
| - |
17 |
| - $transport = $factory->create(Dsn::fromString('linkedin://accessToken:UserId@host.test')); |
18 |
| - |
19 |
| - $this->assertSame('linkedin://host.test', (string) $transport); |
20 |
| - } |
21 |
| - |
22 |
| - public function testCreateWithOnlyAccessTokenOrUserIdThrowsIncompleteDsnException() |
23 |
| - { |
24 |
| - $factory = $this->createFactory(); |
25 |
| - |
26 |
| - $this->expectException(IncompleteDsnException::class); |
27 |
| - $factory->create(Dsn::fromString('linkedin://AccessTokenOrUserId@default')); |
| 16 | + return new LinkedInTransportFactory(); |
28 | 17 | }
|
29 | 18 |
|
30 |
| - public function testSupportsReturnsTrueWithSupportedScheme() |
| 19 | + public function createProvider(): iterable |
31 | 20 | {
|
32 |
| - $factory = $this->createFactory(); |
33 |
| - |
34 |
| - $this->assertTrue($factory->supports(Dsn::fromString('linkedin://host/path'))); |
| 21 | + yield [ |
| 22 | + 'linkedin://host.test', |
| 23 | + 'linkedin://accessToken:UserId@host.test', |
| 24 | + ]; |
35 | 25 | }
|
36 | 26 |
|
37 |
| - public function testSupportsReturnsFalseWithUnsupportedScheme() |
| 27 | + public function supportsProvider(): iterable |
38 | 28 | {
|
39 |
| - $factory = $this->createFactory(); |
40 |
| - |
41 |
| - $this->assertFalse($factory->supports(Dsn::fromString('somethingElse://host/path'))); |
| 29 | + yield [true, 'linkedin://host']; |
| 30 | + yield [false, 'somethingElse://host']; |
42 | 31 | }
|
43 | 32 |
|
44 |
| - public function testUnsupportedSchemeThrowsUnsupportedSchemeException() |
| 33 | + public function incompleteDsnProvider(): iterable |
45 | 34 | {
|
46 |
| - $factory = $this->createFactory(); |
47 |
| - |
48 |
| - $this->expectException(UnsupportedSchemeException::class); |
49 |
| - $factory->create(Dsn::fromString('somethingElse://accessToken:UserId@default')); |
| 35 | + yield 'missing account or user_id' => ['linkedin://AccessTokenOrUserId@default']; |
50 | 36 | }
|
51 | 37 |
|
52 |
| - private function createFactory(): LinkedInTransportFactory |
| 38 | + public function unsupportedSchemeProvider(): iterable |
53 | 39 | {
|
54 |
| - return new LinkedInTransportFactory(); |
| 40 | + yield ['somethingElse://accessToken:UserId@default']; |
55 | 41 | }
|
56 | 42 | }
|
0 commit comments