Skip to content

Commit 32d43b3

Browse files
committed
Improved SonarQube result
1 parent b9c8718 commit 32d43b3

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

tests/lib/Form/EventSubscriber/FixUrlProtocolListenerTest.php

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515

1616
final class FixUrlProtocolListenerTest extends TestCase
1717
{
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+
1828
/**
1929
* @dataProvider provideUrlCases
2030
*
@@ -43,49 +53,49 @@ public function testUrlProtocolHandling(?array $inputData, ?array $expectedData,
4353
public static function provideUrlCases(): iterable
4454
{
4555
yield 'adds http when protocol missing' => [
46-
['link' => 'example1.com'],
47-
['link' => 'http://example1.com'],
56+
['link' => self::DOMAIN],
57+
['link' => self::URL_HTTP],
4858
];
4959

5060
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],
5363
];
5464

5565
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],
5868
];
5969

6070
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],
6373
];
6474

6575
yield 'keeps ftp intact' => [
66-
['link' => 'ftp://example4.com'],
67-
['link' => 'ftp://example4.com'],
76+
['link' => self::URL_SFTP],
77+
['link' => self::URL_SFTP],
6878
];
6979

7080
yield 'keeps tel intact' => [
71-
['link' => 'tel:+123456'],
72-
['link' => 'tel:+123456'],
81+
['link' => self::URL_TEL],
82+
['link' => self::URL_TEL],
7383
];
7484

7585
yield 'adds default tel' => [
76-
['link' => '+123456'],
77-
['link' => 'tel:+123456'],
86+
['link' => self::TEL],
87+
['link' => self::URL_TEL],
7888
'tel',
7989
];
8090

8191
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],
8494
];
8595

8696
yield 'adds default mailto' => [
87-
['link' => 'bar@home'],
88-
['link' => 'mailto:bar@home'],
97+
['link' => self::MAIL],
98+
['link' => self::URL_MAILTO],
8999
'mailto',
90100
];
91101

0 commit comments

Comments
 (0)