@@ -12,15 +12,40 @@ public function setUp()
12
12
13
13
public function testValids ()
14
14
{
15
+ // Without specific schemes
15
16
$ this ->assertTrue ($ this ->rule ->check ('ftp://foobar.com ' ));
17
+ $ this ->assertTrue ($ this ->rule ->check ('any://foobar.com ' ));
16
18
$ this ->assertTrue ($ this ->rule ->check ('http://foobar.com ' ));
17
19
$ this ->assertTrue ($ this ->rule ->check ('https://foobar.com ' ));
18
20
$ this ->assertTrue ($ this ->rule ->check ('https://foobar.com/path?a=123&b=blah ' ));
21
+
22
+ // Using specific schemes
23
+ $ this ->assertTrue ($ this ->rule ->fillParameters (['ftp ' ])->check ('ftp://foobar.com ' ));
24
+ $ this ->assertTrue ($ this ->rule ->fillParameters (['any ' ])->check ('any://foobar.com ' ));
25
+ $ this ->assertTrue ($ this ->rule ->fillParameters (['http ' ])->check ('http://foobar.com ' ));
26
+ $ this ->assertTrue ($ this ->rule ->fillParameters (['https ' ])->check ('https://foobar.com ' ));
27
+ $ this ->assertTrue ($ this ->rule ->fillParameters (['http ' , 'https ' ])->check ('https://foobar.com ' ));
28
+ $ this ->assertTrue ($ this ->rule ->fillParameters (['foo ' , 'bar ' ])->check ('bar://foobar.com ' ));
29
+ $ this ->
assertTrue (
$ this ->
rule ->
fillParameters ([
'mailto ' ])->
check (
'mailto:[email protected] ' ));
30
+ $ this ->assertTrue ($ this ->rule ->fillParameters (['jdbc ' ])->check ('jdbc:mysql://localhost/dbname ' ));
31
+
32
+ // Using forScheme
33
+ $ this ->assertTrue ($ this ->rule ->forScheme ('ftp ' )->check ('ftp://foobar.com ' ));
34
+ $ this ->assertTrue ($ this ->rule ->forScheme ('http ' )->check ('http://foobar.com ' ));
35
+ $ this ->assertTrue ($ this ->rule ->forScheme ('https ' )->check ('https://foobar.com ' ));
36
+ $ this ->assertTrue ($ this ->rule ->forScheme (['http ' , 'https ' ])->check ('https://foobar.com ' ));
37
+ $ this ->
assertTrue (
$ this ->
rule ->
forScheme (
'mailto ' )->
check (
'mailto:[email protected] ' ));
38
+ $ this ->assertTrue ($ this ->rule ->forScheme ('jdbc ' )->check ('jdbc:mysql://localhost/dbname ' ));
19
39
}
20
40
21
41
public function testInvalids ()
22
42
{
23
43
$ this ->assertFalse ($ this ->rule ->check ('foo: ' ));
44
+ $ this ->
assertFalse (
$ this ->
rule ->
check (
'mailto:[email protected] ' ));
45
+ $ this ->assertFalse ($ this ->rule ->forScheme ('mailto ' )->check ('http://www.foobar.com ' ));
46
+ $ this ->assertFalse ($ this ->rule ->forScheme ('ftp ' )->check ('http://www.foobar.com ' ));
47
+ $ this ->assertFalse ($ this ->rule ->forScheme ('jdbc ' )->check ('http://www.foobar.com ' ));
48
+ $ this ->assertFalse ($ this ->rule ->forScheme (['http ' , 'https ' ])->check ('any://www.foobar.com ' ));
24
49
}
25
50
26
51
}
0 commit comments