diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php index da72d6b3a9..72bee71002 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/ApacheMatcherDumperTest.php @@ -150,7 +150,8 @@ class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase $route3 = new Route('/route3', array(), array(), array(), 'b.example.com'); $collection2->add('route3', $route3); - $collection1->addCollection($collection2, '/c2'); + $collection2->addPrefix('/c2'); + $collection1->addCollection($collection2); $route4 = new Route('/route4', array(), array(), array(), 'a.example.com'); $collection1->add('route4', $route4); diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 4764df617d..542ede85c0 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -118,14 +118,17 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $collection1->add('overridden', new Route('/overridden1')); $collection1->add('foo1', new Route('/{foo}')); $collection1->add('bar1', new Route('/{bar}')); + $collection1->addPrefix('/b\'b'); $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b\'b'); + $collection2->addCollection($collection1); $collection2->add('overridden', new Route('/{var}', array(), array('var' => '.*'))); $collection1 = new RouteCollection(); $collection1->add('foo2', new Route('/{foo1}')); $collection1->add('bar2', new Route('/{bar1}')); - $collection2->addCollection($collection1, '/b\'b'); - $collection->addCollection($collection2, '/a'); + $collection1->addPrefix('/b\'b'); + $collection2->addCollection($collection1); + $collection2->addPrefix('/a'); + $collection->addCollection($collection2); // overridden through addCollection() and multiple sub-collections with no own prefix $collection1 = new RouteCollection(); @@ -137,15 +140,16 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $collection3->add('hey', new Route('/hey/')); $collection2->addCollection($collection3); $collection1->addCollection($collection2); - $collection->addCollection($collection1, '/multi'); + $collection1->addPrefix('/multi'); + $collection->addCollection($collection1); // "dynamic" prefix $collection1 = new RouteCollection(); $collection1->add('foo3', new Route('/{foo}')); $collection1->add('bar3', new Route('/{bar}')); - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b'); - $collection->addCollection($collection2, '/{_locale}'); + $collection1->addPrefix('/b'); + $collection1->addPrefix('{_locale}'); + $collection->addCollection($collection1); // route between collections $collection->add('ababa', new Route('/ababa')); @@ -153,7 +157,8 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase // collection with static prefix but only one route $collection1 = new RouteCollection(); $collection1->add('foo4', new Route('/{foo}')); - $collection->addCollection($collection1, '/aba'); + $collection1->addPrefix('/aba'); + $collection->addCollection($collection1); // prefix and host @@ -215,10 +220,12 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $collection2->add('b', new Route('/{var}')); $collection3 = new RouteCollection(); $collection3->add('c', new Route('/{var}')); - - $collection2->addCollection($collection3, '/c'); - $collection1->addCollection($collection2, '/b'); - $collection->addCollection($collection1, '/a'); + $collection3->addPrefix('/c'); + $collection2->addCollection($collection3); + $collection2->addPrefix('/b'); + $collection1->addCollection($collection2); + $collection1->addPrefix('/a'); + $collection->addCollection($collection1); /* test case 2 */ diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index fee6fe2b6f..8a1428f170 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -130,14 +130,10 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase public function testMatchWithPrefixes() { - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/{foo}')); - - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b'); - $collection = new RouteCollection(); - $collection->addCollection($collection2, '/a'); + $collection->add('foo', new Route('/{foo}')); + $collection->addPrefix('/b'); + $collection->addPrefix('/a'); $matcher = new UrlMatcher($collection, new RequestContext()); $this->assertEquals(array('_route' => 'foo', 'foo' => 'foo'), $matcher->match('/a/b/foo')); @@ -145,14 +141,10 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase public function testMatchWithDynamicPrefix() { - $collection1 = new RouteCollection(); - $collection1->add('foo', new Route('/{foo}')); - - $collection2 = new RouteCollection(); - $collection2->addCollection($collection1, '/b'); - $collection = new RouteCollection(); - $collection->addCollection($collection2, '/{_locale}'); + $collection->add('foo', new Route('/{foo}')); + $collection->addPrefix('/b'); + $collection->addPrefix('/{_locale}'); $matcher = new UrlMatcher($collection, new RequestContext()); $this->assertEquals(array('_locale' => 'fr', '_route' => 'foo', 'foo' => 'foo'), $matcher->match('/fr/b/foo'));