@@ -703,6 +703,30 @@ public function testFragmentsCanBeDefinedAsDefaults()
703
703
$ this ->assertEquals ('/app.php/testing#fragment ' , $ url );
704
704
}
705
705
706
+ public function testLookAheadPositiveInRequirements ()
707
+ {
708
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/{foo}/b(ar/{baz} ' , array (), array ('foo ' => '.+(?=/b \\(ar/) ' , 'baz ' => '.+? ' )));
709
+ $ this ->assertSame ('/app.php/a/b/b%28ar/c/d/e ' , $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'a/b ' , 'baz ' => 'c/d/e ' )));
710
+ }
711
+
712
+ public function testLookAheadNegativeInRequirementss ()
713
+ {
714
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/{foo}/bar/{baz} ' , array (), array ('foo ' => '.+(?!$) ' , 'baz ' => '.+? ' )));
715
+ $ this ->assertSame ('/app.php/a/b/bar/c/d/e ' , $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'a/b ' , 'baz ' => 'c/d/e ' )));
716
+ }
717
+
718
+ public function testLookBehindPositiveInRequirements ()
719
+ {
720
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/bar/{foo}/bam/{baz} ' , array (), array ('foo ' => '(?<=/bar/).+ ' , 'baz ' => '.+? ' )));
721
+ $ this ->assertSame ('/app.php/bar/a/b/bam/c/d/e ' , $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'a/b ' , 'baz ' => 'c/d/e ' )));
722
+ }
723
+
724
+ public function testLookBehindNegativeInRequirements ()
725
+ {
726
+ $ routes = $ this ->getRoutes ('test ' , new Route ('/bar/{foo}/bam/{baz} ' , array (), array ('foo ' => '(?<!^).+ ' , 'baz ' => '.+? ' )));
727
+ $ this ->assertSame ('/app.php/bar/a/b/bam/c/d/e ' , $ this ->getGenerator ($ routes )->generate ('test ' , array ('foo ' => 'a/b ' , 'baz ' => 'c/d/e ' )));
728
+ }
729
+
706
730
protected function getGenerator (RouteCollection $ routes , array $ parameters = array (), $ logger = null )
707
731
{
708
732
$ context = new RequestContext ('/app.php ' );
0 commit comments