@@ -12,15 +12,40 @@ public function setUp()
1212
1313 public function testValids ()
1414 {
15+ // Without specific schemes
1516 $ this ->assertTrue ($ this ->rule ->check ('ftp://foobar.com ' ));
17+ $ this ->assertTrue ($ this ->rule ->check ('any://foobar.com ' ));
1618 $ this ->assertTrue ($ this ->rule ->check ('http://foobar.com ' ));
1719 $ this ->assertTrue ($ this ->rule ->check ('https://foobar.com ' ));
1820 $ 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 ' ));
1939 }
2040
2141 public function testInvalids ()
2242 {
2343 $ 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 ' ));
2449 }
2550
2651}
0 commit comments