@@ -734,6 +734,32 @@ public function testPreviousPath()
734
734
$ this ->assertSame ('/bar ' , $ url ->previousPath ('/bar ' ));
735
735
}
736
736
737
+ public function testWhenPreviousIsEqualToCurrent ()
738
+ {
739
+ $ url = new UrlGenerator (
740
+ new RouteCollection ,
741
+ Request::create ('http://www.foo.com/ ' )
742
+ );
743
+
744
+ $ url ->getRequest ()->headers ->set ('referer ' , 'http://www.foo.com/ ' );
745
+ $ this ->assertSame ('http://www.foo.com ' , $ url ->previous ());
746
+ $ this ->assertSame ('http://www.foo.com/bar ' , $ url ->previous ('/bar ' ));
747
+
748
+ $ url ->setRequest (Request::create ('http://www.foo.com/bar ' ));
749
+
750
+ $ url ->getRequest ()->headers ->set ('referer ' , 'http://www.foo.com/bar ' );
751
+ $ this ->assertSame ('http://www.foo.com ' , $ url ->previous ());
752
+ $ this ->assertSame ('http://www.foo.com/bar ' , $ url ->previous ('/bar ' ));
753
+ $ this ->assertSame ('http://www.foo.com/baz ' , $ url ->previous ('/baz ' ));
754
+
755
+ $ url ->setRequest (Request::create ('http://www.foo.com/bar?page=2 ' ));
756
+
757
+ $ url ->getRequest ()->headers ->set ('referer ' , 'http://www.foo.com/bar?page=2 ' );
758
+ $ this ->assertSame ('http://www.foo.com ' , $ url ->previous ());
759
+ $ this ->assertSame ('http://www.foo.com/bar ' , $ url ->previous ('/bar ' ));
760
+ $ this ->assertSame ('http://www.foo.com/bar?page=2 ' , $ url ->previous ('/bar?page=2 ' ));
761
+ }
762
+
737
763
public function testRouteNotDefinedException ()
738
764
{
739
765
$ this ->expectException (RouteNotFoundException::class);
0 commit comments