|
15 | 15 |
|
16 | 16 | final class FixUrlProtocolListenerTest extends TestCase |
17 | 17 | { |
| 18 | + private const DOMAIN = 'example.com'; |
| 19 | + private const MAIL = 'foo@' . self::DOMAIN; |
| 20 | + private const TEL = '+123456'; |
| 21 | + private const URL_HTTP = 'http://' . self::DOMAIN; |
| 22 | + private const URL_HTTPS = 'https://' . self::DOMAIN; |
| 23 | + private const URL_MAILTO = 'mailto:' . self::MAIL; |
| 24 | + private const URL_RELATIVE = '/foo/bar/'; |
| 25 | + private const URL_SFTP = 'sftp://' . self::DOMAIN; |
| 26 | + private const URL_TEL = 'tel:' . self::TEL; |
| 27 | + |
18 | 28 | /** |
19 | 29 | * @dataProvider provideUrlCases |
20 | 30 | * |
@@ -43,49 +53,49 @@ public function testUrlProtocolHandling(?array $inputData, ?array $expectedData, |
43 | 53 | public static function provideUrlCases(): iterable |
44 | 54 | { |
45 | 55 | yield 'adds http when protocol missing' => [ |
46 | | - ['link' => 'example1.com'], |
47 | | - ['link' => 'http://example1.com'], |
| 56 | + ['link' => self::DOMAIN], |
| 57 | + ['link' => self::URL_HTTP], |
48 | 58 | ]; |
49 | 59 |
|
50 | 60 | yield 'does not modify https url' => [ |
51 | | - ['link' => 'https://example2.com'], |
52 | | - ['link' => 'https://example2.com'], |
| 61 | + ['link' => self::URL_HTTPS], |
| 62 | + ['link' => self::URL_HTTPS], |
53 | 63 | ]; |
54 | 64 |
|
55 | 65 | yield 'does not modify http url' => [ |
56 | | - ['link' => 'http://example3.com'], |
57 | | - ['link' => 'http://example3.com'], |
| 66 | + ['link' => self::URL_HTTP], |
| 67 | + ['link' => self::URL_HTTP], |
58 | 68 | ]; |
59 | 69 |
|
60 | 70 | yield 'keep relative url with leading / intact' => [ |
61 | | - ['link' => '/foo/bar'], |
62 | | - ['link' => '/foo/bar'], |
| 71 | + ['link' => self::URL_RELATIVE], |
| 72 | + ['link' => self::URL_RELATIVE], |
63 | 73 | ]; |
64 | 74 |
|
65 | 75 | yield 'keeps ftp intact' => [ |
66 | | - ['link' => 'ftp://example4.com'], |
67 | | - ['link' => 'ftp://example4.com'], |
| 76 | + ['link' => self::URL_SFTP], |
| 77 | + ['link' => self::URL_SFTP], |
68 | 78 | ]; |
69 | 79 |
|
70 | 80 | yield 'keeps tel intact' => [ |
71 | | - ['link' => 'tel:+123456'], |
72 | | - ['link' => 'tel:+123456'], |
| 81 | + ['link' => self::URL_TEL], |
| 82 | + ['link' => self::URL_TEL], |
73 | 83 | ]; |
74 | 84 |
|
75 | 85 | yield 'adds default tel' => [ |
76 | | - ['link' => '+123456'], |
77 | | - ['link' => 'tel:+123456'], |
| 86 | + ['link' => self::TEL], |
| 87 | + ['link' => self::URL_TEL], |
78 | 88 | 'tel', |
79 | 89 | ]; |
80 | 90 |
|
81 | 91 | yield 'keeps mailto intact' => [ |
82 | | - ['link' => 'mailto:foo@home.com'], |
83 | | - ['link' => 'mailto:foo@home.com'], |
| 92 | + ['link' => self::URL_MAILTO], |
| 93 | + ['link' => self::URL_MAILTO], |
84 | 94 | ]; |
85 | 95 |
|
86 | 96 | yield 'adds default mailto' => [ |
87 | | - ['link' => 'bar@home'], |
88 | | - ['link' => 'mailto:bar@home'], |
| 97 | + ['link' => self::MAIL], |
| 98 | + ['link' => self::URL_MAILTO], |
89 | 99 | 'mailto', |
90 | 100 | ]; |
91 | 101 |
|
|
0 commit comments