Permalink
Browse files

added tests for addDefaults, addRequirements, addOptions

  • Loading branch information...
1 parent 3dbe725 commit a0e66ba15e777b29550a130abcadbfc1330990ee @Tobion Tobion committed Dec 7, 2012
Showing with 27 additions and 0 deletions.
  1. +27 −0 Tests/RouteCollectionTest.php
@@ -115,6 +115,33 @@ public function testAddCollectionWithResources()
$this->assertEquals(array($foo, $foo1), $collection->getResources(), '->addCollection() merges resources');
}
+ public function testAddDefaultsAndRequirementsAndOptions()
+ {
+ $collection = new RouteCollection();
+ $collection->add('foo', new Route('/{placeholder}'));
+ $collection1 = new RouteCollection();
+ $collection1->add('bar', new Route('/{placeholder}',
+ array('_controller' => 'fixed', 'placeholder' => 'default'), array('placeholder' => '.+'), array('option' => 'value'))
+ );
+ $collection->addCollection($collection1);
+
+ $collection->addDefaults(array('placeholder' => 'new-default'));
+ $this->assertEquals(array('placeholder' => 'new-default'), $collection->get('foo')->getDefaults(), '->addDefaults() adds defaults to all routes');
+ $this->assertEquals(array('_controller' => 'fixed', 'placeholder' => 'new-default'), $collection->get('bar')->getDefaults(),
+ '->addDefaults() adds defaults to all routes and overwrites existing ones');
+
+ $collection->addRequirements(array('placeholder' => '\d+'));
+ $this->assertEquals(array('placeholder' => '\d+'), $collection->get('foo')->getRequirements(), '->addRequirements() adds requirements to all routes');
+ $this->assertEquals(array('placeholder' => '\d+'), $collection->get('bar')->getRequirements(),
+ '->addRequirements() adds requirements to all routes and overwrites existing ones');
+
+ $collection->addOptions(array('option' => 'new-value'));
+ $this->assertEquals(
+ array('option' => 'new-value', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'),
+ $collection->get('bar')->getOptions(), '->addOptions() adds options to all routes and overwrites existing ones'
+ );
+ }
+
public function testAddPrefix()
{
$collection = new RouteCollection();

0 comments on commit a0e66ba

Please sign in to comment.