1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace EcodevTests\Felix\Api\Scalar; |
6
|
|
|
|
7
|
|
|
use Ecodev\Felix\Api\Scalar\UrlType; |
8
|
|
|
|
9
|
|
|
final class UrlTypeTest extends AbstractStringBasedType |
10
|
|
|
{ |
11
|
|
|
public function createType(): \Ecodev\Felix\Api\Scalar\AbstractStringBasedType |
12
|
|
|
{ |
13
|
|
|
return new UrlType(); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function getTypeName(): string |
17
|
|
|
{ |
18
|
|
|
return 'Url'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function providerValues(): iterable |
22
|
|
|
{ |
23
|
|
|
return [ |
24
|
|
|
|
25
|
|
|
['http://www.example.com', 'http://www.example.com', true], |
26
|
|
|
['https://www.example.com', 'https://www.example.com', true], |
27
|
|
|
['http://example.com', 'http://example.com', true], |
28
|
|
|
['http://www.example.com/path', 'http://www.example.com/path', true], |
29
|
|
|
['http://www.example.com/path#frag', 'http://www.example.com/path#frag', true], |
30
|
|
|
['http://www.example.com/path?param=1', 'http://www.example.com/path?param=1', true], |
31
|
|
|
['http://www.example.com/path?param=1#fra', 'http://www.example.com/path?param=1#fra', true], |
32
|
|
|
['http://t.co', 'http://t.co', true], |
33
|
|
|
['http://www.t.co', 'http://www.t.co', true], |
34
|
|
|
['http://a-b.c.t.co', 'http://a-b.c.t.co', true], |
35
|
|
|
['http://aa.com', 'http://aa.com', true], |
36
|
|
|
['http://www.example', 'http://www.example', true], // this is indeed valid because `example` could be a TLD |
37
|
|
|
['https://example.com:4200/subscribe', 'https://example.com:4200/subscribe', true], |
38
|
|
|
['https://example-.com', 'https://example-.com', true], // this is not conform to rfc1738, but we tolerate it for simplicity sake |
39
|
|
|
|
40
|
|
|
['www.example.com', 'www.example.com', false], |
41
|
|
|
['example.com', 'example.com', false], |
42
|
|
|
['www.example', 'www.example', false], |
43
|
|
|
['http://example', 'http://example', false], |
44
|
|
|
['www.example#.com', 'www.example#.com', false], |
45
|
|
|
['www.t.co', 'www.t.co', false], |
46
|
|
|
['file:///C:/folder/file.pdf', 'file:///C:/folder/file.pdf', false], |
47
|
|
|
|
48
|
|
|
['', '', false], |
49
|
|
|
[null, null, false], |
50
|
|
|
[' ', ' ', false], |
51
|
|
|
]; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|