Skip to content

Commit 12c8017

Browse files
committed
Minor fix
1 parent 32d43b3 commit 12c8017

2 files changed

Lines changed: 52 additions & 61 deletions

File tree

src/lib/Form/EventSubscriber/FixUrlProtocolListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function onSubmit(FormEvent $event): void
6868

6969
private function hasAuthority(string $protocol): bool
7070
{
71-
return in_array($protocol, ['mailto', 'tel']) ? false : true;
71+
return !in_array($protocol, ['mailto', 'tel']);
7272
}
7373

7474
public static function getSubscribedEvents(): array

tests/lib/Form/EventSubscriber/FixUrlProtocolListenerTest.php

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -52,66 +52,57 @@ public function testUrlProtocolHandling(?array $inputData, ?array $expectedData,
5252
*/
5353
public static function provideUrlCases(): iterable
5454
{
55-
yield 'adds http when protocol missing' => [
56-
['link' => self::DOMAIN],
57-
['link' => self::URL_HTTP],
58-
];
59-
60-
yield 'does not modify https url' => [
61-
['link' => self::URL_HTTPS],
62-
['link' => self::URL_HTTPS],
63-
];
64-
65-
yield 'does not modify http url' => [
66-
['link' => self::URL_HTTP],
67-
['link' => self::URL_HTTP],
68-
];
69-
70-
yield 'keep relative url with leading / intact' => [
71-
['link' => self::URL_RELATIVE],
72-
['link' => self::URL_RELATIVE],
73-
];
74-
75-
yield 'keeps ftp intact' => [
76-
['link' => self::URL_SFTP],
77-
['link' => self::URL_SFTP],
78-
];
79-
80-
yield 'keeps tel intact' => [
81-
['link' => self::URL_TEL],
82-
['link' => self::URL_TEL],
83-
];
84-
85-
yield 'adds default tel' => [
86-
['link' => self::TEL],
87-
['link' => self::URL_TEL],
88-
'tel',
89-
];
90-
91-
yield 'keeps mailto intact' => [
92-
['link' => self::URL_MAILTO],
93-
['link' => self::URL_MAILTO],
94-
];
95-
96-
yield 'adds default mailto' => [
97-
['link' => self::MAIL],
98-
['link' => self::URL_MAILTO],
99-
'mailto',
100-
];
101-
102-
yield 'does nothing when link is empty string' => [
103-
['link' => ''],
104-
['link' => ''],
105-
];
106-
107-
yield 'does nothing when link key is missing' => [
108-
[],
109-
[],
110-
];
111-
112-
yield 'does nothing when data is null' => [
113-
null,
114-
null,
55+
return [
56+
'adds http when protocol missing' => [
57+
['link' => self::DOMAIN],
58+
['link' => self::URL_HTTP],
59+
],
60+
'does not modify https url' => [
61+
['link' => self::URL_HTTPS],
62+
['link' => self::URL_HTTPS],
63+
],
64+
'does not modify http url' => [
65+
['link' => self::URL_HTTP],
66+
['link' => self::URL_HTTP],
67+
],
68+
'keep relative url with leading / intact' => [
69+
['link' => self::URL_RELATIVE],
70+
['link' => self::URL_RELATIVE],
71+
],
72+
'keeps ftp intact' => [
73+
['link' => self::URL_SFTP],
74+
['link' => self::URL_SFTP],
75+
],
76+
'keeps tel intact' => [
77+
['link' => self::URL_TEL],
78+
['link' => self::URL_TEL],
79+
],
80+
'adds default tel' => [
81+
['link' => self::TEL],
82+
['link' => self::URL_TEL],
83+
'tel',
84+
],
85+
'keeps mailto intact' => [
86+
['link' => self::URL_MAILTO],
87+
['link' => self::URL_MAILTO],
88+
],
89+
'adds default mailto' => [
90+
['link' => self::MAIL],
91+
['link' => self::URL_MAILTO],
92+
'mailto',
93+
],
94+
'does nothing when link is empty string' => [
95+
['link' => ''],
96+
['link' => ''],
97+
],
98+
'does nothing when link key is missing' => [
99+
[],
100+
[],
101+
],
102+
'does nothing when data is null' => [
103+
null,
104+
null,
105+
],
115106
];
116107
}
117108
}

0 commit comments

Comments
 (0)