adjust routing tests to not use prefix in addCollection
This commit is contained in:
parent
6180c5b031
commit
708c0d3ff9
@ -150,7 +150,8 @@ class ApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$route3 = new Route('/route3', array(), array(), array(), 'b.example.com');
|
$route3 = new Route('/route3', array(), array(), array(), 'b.example.com');
|
||||||
$collection2->add('route3', $route3);
|
$collection2->add('route3', $route3);
|
||||||
|
|
||||||
$collection1->addCollection($collection2, '/c2');
|
$collection2->addPrefix('/c2');
|
||||||
|
$collection1->addCollection($collection2);
|
||||||
|
|
||||||
$route4 = new Route('/route4', array(), array(), array(), 'a.example.com');
|
$route4 = new Route('/route4', array(), array(), array(), 'a.example.com');
|
||||||
$collection1->add('route4', $route4);
|
$collection1->add('route4', $route4);
|
||||||
|
@ -118,14 +118,17 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$collection1->add('overridden', new Route('/overridden1'));
|
$collection1->add('overridden', new Route('/overridden1'));
|
||||||
$collection1->add('foo1', new Route('/{foo}'));
|
$collection1->add('foo1', new Route('/{foo}'));
|
||||||
$collection1->add('bar1', new Route('/{bar}'));
|
$collection1->add('bar1', new Route('/{bar}'));
|
||||||
|
$collection1->addPrefix('/b\'b');
|
||||||
$collection2 = new RouteCollection();
|
$collection2 = new RouteCollection();
|
||||||
$collection2->addCollection($collection1, '/b\'b');
|
$collection2->addCollection($collection1);
|
||||||
$collection2->add('overridden', new Route('/{var}', array(), array('var' => '.*')));
|
$collection2->add('overridden', new Route('/{var}', array(), array('var' => '.*')));
|
||||||
$collection1 = new RouteCollection();
|
$collection1 = new RouteCollection();
|
||||||
$collection1->add('foo2', new Route('/{foo1}'));
|
$collection1->add('foo2', new Route('/{foo1}'));
|
||||||
$collection1->add('bar2', new Route('/{bar1}'));
|
$collection1->add('bar2', new Route('/{bar1}'));
|
||||||
$collection2->addCollection($collection1, '/b\'b');
|
$collection1->addPrefix('/b\'b');
|
||||||
$collection->addCollection($collection2, '/a');
|
$collection2->addCollection($collection1);
|
||||||
|
$collection2->addPrefix('/a');
|
||||||
|
$collection->addCollection($collection2);
|
||||||
|
|
||||||
// overridden through addCollection() and multiple sub-collections with no own prefix
|
// overridden through addCollection() and multiple sub-collections with no own prefix
|
||||||
$collection1 = new RouteCollection();
|
$collection1 = new RouteCollection();
|
||||||
@ -137,15 +140,16 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$collection3->add('hey', new Route('/hey/'));
|
$collection3->add('hey', new Route('/hey/'));
|
||||||
$collection2->addCollection($collection3);
|
$collection2->addCollection($collection3);
|
||||||
$collection1->addCollection($collection2);
|
$collection1->addCollection($collection2);
|
||||||
$collection->addCollection($collection1, '/multi');
|
$collection1->addPrefix('/multi');
|
||||||
|
$collection->addCollection($collection1);
|
||||||
|
|
||||||
// "dynamic" prefix
|
// "dynamic" prefix
|
||||||
$collection1 = new RouteCollection();
|
$collection1 = new RouteCollection();
|
||||||
$collection1->add('foo3', new Route('/{foo}'));
|
$collection1->add('foo3', new Route('/{foo}'));
|
||||||
$collection1->add('bar3', new Route('/{bar}'));
|
$collection1->add('bar3', new Route('/{bar}'));
|
||||||
$collection2 = new RouteCollection();
|
$collection1->addPrefix('/b');
|
||||||
$collection2->addCollection($collection1, '/b');
|
$collection1->addPrefix('{_locale}');
|
||||||
$collection->addCollection($collection2, '/{_locale}');
|
$collection->addCollection($collection1);
|
||||||
|
|
||||||
// route between collections
|
// route between collections
|
||||||
$collection->add('ababa', new Route('/ababa'));
|
$collection->add('ababa', new Route('/ababa'));
|
||||||
@ -153,7 +157,8 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
// collection with static prefix but only one route
|
// collection with static prefix but only one route
|
||||||
$collection1 = new RouteCollection();
|
$collection1 = new RouteCollection();
|
||||||
$collection1->add('foo4', new Route('/{foo}'));
|
$collection1->add('foo4', new Route('/{foo}'));
|
||||||
$collection->addCollection($collection1, '/aba');
|
$collection1->addPrefix('/aba');
|
||||||
|
$collection->addCollection($collection1);
|
||||||
|
|
||||||
// prefix and host
|
// prefix and host
|
||||||
|
|
||||||
@ -215,10 +220,12 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$collection2->add('b', new Route('/{var}'));
|
$collection2->add('b', new Route('/{var}'));
|
||||||
$collection3 = new RouteCollection();
|
$collection3 = new RouteCollection();
|
||||||
$collection3->add('c', new Route('/{var}'));
|
$collection3->add('c', new Route('/{var}'));
|
||||||
|
$collection3->addPrefix('/c');
|
||||||
$collection2->addCollection($collection3, '/c');
|
$collection2->addCollection($collection3);
|
||||||
$collection1->addCollection($collection2, '/b');
|
$collection2->addPrefix('/b');
|
||||||
$collection->addCollection($collection1, '/a');
|
$collection1->addCollection($collection2);
|
||||||
|
$collection1->addPrefix('/a');
|
||||||
|
$collection->addCollection($collection1);
|
||||||
|
|
||||||
/* test case 2 */
|
/* test case 2 */
|
||||||
|
|
||||||
|
@ -130,14 +130,10 @@ class UrlMatcherTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testMatchWithPrefixes()
|
public function testMatchWithPrefixes()
|
||||||
{
|
{
|
||||||
$collection1 = new RouteCollection();
|
|
||||||
$collection1->add('foo', new Route('/{foo}'));
|
|
||||||
|
|
||||||
$collection2 = new RouteCollection();
|
|
||||||
$collection2->addCollection($collection1, '/b');
|
|
||||||
|
|
||||||
$collection = new RouteCollection();
|
$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());
|
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||||
$this->assertEquals(array('_route' => 'foo', 'foo' => 'foo'), $matcher->match('/a/b/foo'));
|
$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()
|
public function testMatchWithDynamicPrefix()
|
||||||
{
|
{
|
||||||
$collection1 = new RouteCollection();
|
|
||||||
$collection1->add('foo', new Route('/{foo}'));
|
|
||||||
|
|
||||||
$collection2 = new RouteCollection();
|
|
||||||
$collection2->addCollection($collection1, '/b');
|
|
||||||
|
|
||||||
$collection = new RouteCollection();
|
$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());
|
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||||
$this->assertEquals(array('_locale' => 'fr', '_route' => 'foo', 'foo' => 'foo'), $matcher->match('/fr/b/foo'));
|
$this->assertEquals(array('_locale' => 'fr', '_route' => 'foo', 'foo' => 'foo'), $matcher->match('/fr/b/foo'));
|
||||||
|
Reference in New Issue
Block a user