@@ -578,4 +578,128 @@ public function testWithFragmentReturnsSameInstanceWhenFragmentIsUnchangedEncode
578578 $ this ->assertSame ($ uri , $ new );
579579 $ this ->assertEquals ('section%20new%20text! ' , $ uri ->getFragment ());
580580 }
581+
582+ public static function provideResolveUris ()
583+ {
584+ return array (
585+ array (
586+ 'http://localhost/ ' ,
587+ '' ,
588+ 'http://localhost/ '
589+ ),
590+ array (
591+ 'http://localhost/ ' ,
592+ 'http://example.com/ ' ,
593+ 'http://example.com/ '
594+ ),
595+ array (
596+ 'http://localhost/ ' ,
597+ 'path ' ,
598+ 'http://localhost/path '
599+ ),
600+ array (
601+ 'http://localhost/ ' ,
602+ 'path/ ' ,
603+ 'http://localhost/path/ '
604+ ),
605+ array (
606+ 'http://localhost/ ' ,
607+ 'path// ' ,
608+ 'http://localhost/path/ '
609+ ),
610+ array (
611+ 'http://localhost ' ,
612+ 'path ' ,
613+ 'http://localhost/path '
614+ ),
615+ array (
616+ 'http://localhost/a/b ' ,
617+ '/path ' ,
618+ 'http://localhost/path '
619+ ),
620+ array (
621+ 'http://localhost/ ' ,
622+ '/a/b/c ' ,
623+ 'http://localhost/a/b/c '
624+ ),
625+ array (
626+ 'http://localhost/a/path ' ,
627+ 'b/c ' ,
628+ 'http://localhost/a/b/c '
629+ ),
630+ array (
631+ 'http://localhost/a/path ' ,
632+ '/b/c ' ,
633+ 'http://localhost/b/c '
634+ ),
635+ array (
636+ 'http://localhost/a/path/ ' ,
637+ 'b/c ' ,
638+ 'http://localhost/a/path/b/c '
639+ ),
640+ array (
641+ 'http://localhost/a/path/ ' ,
642+ '../b/c ' ,
643+ 'http://localhost/a/b/c '
644+ ),
645+ array (
646+ 'http://localhost ' ,
647+ '../../../a/b ' ,
648+ 'http://localhost/a/b '
649+ ),
650+ array (
651+ 'http://localhost/path ' ,
652+ '?query ' ,
653+ 'http://localhost/path?query '
654+ ),
655+ array (
656+ 'http://localhost/path ' ,
657+ '#fragment ' ,
658+ 'http://localhost/path#fragment '
659+ ),
660+ array (
661+ 'http://localhost/path ' ,
662+ 'http://localhost ' ,
663+ 'http://localhost '
664+ ),
665+ array (
666+ 'http://localhost/path ' ,
667+ 'http://localhost/?query#fragment ' ,
668+ 'http://localhost/?query#fragment '
669+ ),
670+ array (
671+ 'http://localhost/path/?a#fragment ' ,
672+ '?b ' ,
673+ 'http://localhost/path/?b '
674+ ),
675+ array (
676+ 'http://localhost/path ' ,
677+ '//localhost ' ,
678+ 'http://localhost '
679+ ),
680+ array (
681+ 'http://localhost/path ' ,
682+ '//localhost/a?query ' ,
683+ 'http://localhost/a?query '
684+ ),
685+ array (
686+ 'http://localhost/path ' ,
687+ '//LOCALHOST ' ,
688+ 'http://localhost '
689+ )
690+ );
691+ }
692+
693+ /**
694+ * @dataProvider provideResolveUris
695+ * @param string $base
696+ * @param string $rel
697+ * @param string $expected
698+ */
699+ public function testResolveReturnsResolvedUri ($ base , $ rel , $ expected )
700+ {
701+ $ uri = Uri::resolve (new Uri ($ base ), new Uri ($ rel ));
702+
703+ $ this ->assertEquals ($ expected , (string ) $ uri );
704+ }
581705}
0 commit comments