@@ -22,47 +22,51 @@ public function testIsRelativeWillReturnFalse($url)
2222 $ this ->assertFalse (BaseUrl::isRelative ($ url ));
2323 }
2424
25- public function testEnsureSchemeWithRelativeUrlWillReturnInputUrl ()
25+ /** @dataProvider ensureSchemeUrlProvider */
26+ public function testEnsureScheme ()
2627 {
27- $ url = 'acme.com?name=bugs.bunny ' ;
28- $ this ->assertEquals ('acme.com?name=bugs.bunny ' , BaseUrl::ensureScheme ($ url , 'https ' ));
29- }
30-
31- public function testEnsureSchemeWithRelativeUrlWithAnotherUrlAsParamWillReturnInputUrl ()
32- {
33- $ this ->assertEquals ('acme.com/test?tnt-link=https://tnt.com/ ' ,
34- BaseUrl::ensureScheme ('acme.com/test?tnt-link=https://tnt.com/ ' , 'https ' )
35- );
36- }
37-
38- public function testEnsureSchemeWithSchemeNotAStringWillReturnInputUrl ()
39- {
40- $ url = 'acme.com?name=bugs.bunny ' ;
41- $ this ->assertEquals ('acme.com?name=bugs.bunny ' , BaseUrl::ensureScheme ($ url , 123 ));
42- }
43-
44- public function testEnsureSchemeWithProtocolRelativeUrlAndHttpsSchemeWillBeNormalized ()
45- {
46- $ url = '//acme.com?characters/list ' ;
47- $ this ->assertEquals ('https://acme.com?characters/list ' , BaseUrl::ensureScheme ($ url , 'https ' ));
48- }
4928
50- public function testEnsureSchemeWithProtocolRelativeUrlAndEmptySchemeWillBeReturned ()
51- {
52- $ url = '//acme.com?characters/list ' ;
53- $ this ->assertEquals ('//acme.com?characters/list ' , BaseUrl::ensureScheme ($ url , '' ));
5429 }
5530
56- public function testAbsoluteUrlProtocolAndEmptySchemeWillCreateProtocolRelativeUrl ()
31+ public function ensureSchemeUrlProvider ()
5732 {
58- $ url = 'https://acme.com?characters/list ' ;
59- $ this ->assertEquals ('//acme.com?characters/list ' , BaseUrl::ensureScheme ($ url , '' ));
60- }
61-
62- public function testEnsureSchemeWithAbsoluteUrlWithAnotherUrlAsParamWillReturnInputUrl ()
63- {
64- $ url = 'ss://acme.com/test?tnt-link=https://tnt.com/ ' ;
65- $ this ->assertEquals ('https://acme.com/test?tnt-link=https://tnt.com/ ' , BaseUrl::ensureScheme ($ url , 'https ' ));
33+ return [
34+ 'relative url and https scheme will return input url ' => [
35+ 'url ' => 'acme.com?name=bugs.bunny ' ,
36+ 'scheme ' => 'https ' ,
37+ 'expected result ' => 'acme.com?name=bugs.bunny ' ,
38+ ],
39+ 'relative url and another url as parameter will return input url ' => [
40+ 'url ' => 'acme.com/test?tnt-link=https://tnt.com/ ' ,
41+ 'scheme ' => 'https ' ,
42+ 'expected ' => 'acme.com/test?tnt-link=https://tnt.com/ ' ,
43+ ],
44+ 'url with scheme not a string will return input url ' => [
45+ 'url ' => 'acme.com?name=bugs.bunny ' ,
46+ 'scheme ' => 123 ,
47+ 'expected ' => 'acme.com?name=bugs.bunny ' ,
48+ ],
49+ 'protocol relative url and https scheme will be processed ' => [
50+ 'url ' => '//acme.com?characters/list ' ,
51+ 'scheme ' => 'https ' ,
52+ 'expected ' => 'https://acme.com?characters/list ' ,
53+ ],
54+ 'protocol relative url and empty scheme will be returned ' => [
55+ 'url ' => '//acme.com?characters/list ' ,
56+ 'scheme ' => '' ,
57+ 'expected ' => '//acme.com?characters/list ' ,
58+ ],
59+ 'absolute url and empty scheme will create protocol relative url ' => [
60+ 'url ' => 'https://acme.com?characters/list ' ,
61+ 'scheme ' => '' ,
62+ 'expected ' => '//acme.com?characters/list ' ,
63+ ],
64+ 'absolute url and different scheme will be processed ' => [
65+ 'url ' => 'http://acme.com/test?tnt-link=https://tnt.com/ ' ,
66+ 'scheme ' => 'https ' ,
67+ 'expected ' => 'https://acme.com/test?tnt-link=https://tnt.com/ ' ,
68+ ]
69+ ];
6670 }
6771
6872 public function relativeTrueUrlProvider ()
0 commit comments