|
@@ -96,6 +96,19 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertInternalType('array', $matcher->match('/foo'));
|
|
|
$matcher = new UrlMatcher($collection, new RequestContext('', 'head'), array());
|
|
|
$this->assertInternalType('array', $matcher->match('/foo'));
|
|
|
+
|
|
|
+ // route with an optional variable as the first segment
|
|
|
+ $collection = new RouteCollection();
|
|
|
+ $collection->add('bar', new Route('/{bar}/foo', array('bar' => 'bar'), array('bar' => 'foo|bar')));
|
|
|
+ $matcher = new UrlMatcher($collection, new RequestContext(), array());
|
|
|
+ $this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/bar/foo'));
|
|
|
+ $this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo/foo'));
|
|
|
+
|
|
|
+ $collection = new RouteCollection();
|
|
|
+ $collection->add('bar', new Route('/{bar}', array('bar' => 'bar'), array('bar' => 'foo|bar')));
|
|
|
+ $matcher = new UrlMatcher($collection, new RequestContext(), array());
|
|
|
+ $this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo'));
|
|
|
+ $this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/'));
|
|
|
}
|
|
|
|
|
|
public function testMatchRegression()
|