@@ -65,6 +65,34 @@ public function testSameUrl() : void
6565 self ::assertSame ($ expected , $ url ->__toString ());
6666 }
6767
68+ public function testRelative () : void
69+ {
70+ $ url = 'http://domain.tld ' ;
71+ $ object = new URL ($ url );
72+ self ::assertNotSame ('' , $ object ->getRelative ());
73+ $ url = 'http://domain.tld/ ' ;
74+ $ object = new URL ($ url );
75+ self ::assertSame ('/ ' , $ object ->getRelative ());
76+ $ url = 'http://domain.tld?foo=bar ' ;
77+ $ object = new URL ($ url );
78+ self ::assertSame ('/?foo=bar ' , $ object ->getRelative ());
79+ $ url = 'http://domain.tld/?foo=bar ' ;
80+ $ object = new URL ($ url );
81+ self ::assertSame ('/?foo=bar ' , $ object ->getRelative ());
82+ $ url = 'http://domain.tld#contact ' ;
83+ $ object = new URL ($ url );
84+ self ::assertSame ('/#contact ' , $ object ->getRelative ());
85+ $ url = 'http://domain.tld/?foo=bar#contact ' ;
86+ $ object = new URL ($ url );
87+ self ::assertSame ('/?foo=bar#contact ' , $ object ->getRelative ());
88+ $ url = 'http://domain.tld/foo/bar#contact ' ;
89+ $ object = new URL ($ url );
90+ self ::assertSame ('/foo/bar#contact ' , $ object ->getRelative ());
91+ $ url = 'http://domain.tld/foo/bar/#contact ' ;
92+ $ object = new URL ($ url );
93+ self ::assertSame ('/foo/bar/#contact ' , $ object ->getRelative ());
94+ }
95+
6896 public function testPathEndsWithBar () : void
6997 {
7098 $ url = 'http://domain.tld ' ;
0 commit comments