Permalink
Browse files

added tests for remove() that wasnt covered yet and special route name

  • Loading branch information...
1 parent bc21687 commit ec69fcb36b61555d1c6e81004edd0a9546f37f17 @Tobion Tobion committed Dec 7, 2012
Showing with 18 additions and 0 deletions.
  1. +18 −0 Tests/RouteCollectionTest.php
@@ -197,13 +197,31 @@ public function testGet()
$collection2 = new RouteCollection();
$collection2->add('b', $b = new Route('/b'));
$collection1->addCollection($collection2);
+ $collection1->add('$péß^a|', $c = new Route('/special'));
$this->assertSame($b, $collection1->get('b'), '->get() returns correct route in child collection');
+ $this->assertSame($c, $collection1->get('$péß^a|'), '->get() can handle special characters');
$this->assertNull($collection2->get('a'), '->get() does not return the route defined in parent collection');
$this->assertNull($collection1->get('non-existent'), '->get() returns null when route does not exist');
$this->assertNull($collection1->get(0), '->get() does not disclose internal child RouteCollection');
}
+ public function testRemove()
+ {
+ $collection = new RouteCollection();
+ $collection->add('foo', $foo = new Route('/foo'));
+
+ $collection1 = new RouteCollection();
+ $collection1->add('bar', $bar = new Route('/bar'));
+ $collection->addCollection($collection1);
+ $collection->add('last', $last = new Route('/last'));
+
+ $collection->remove('foo');
+ $this->assertSame(array('bar' => $bar, 'last' => $last), $collection->all(), '->remove() can remove a single route');
+ $collection->remove(array('bar', 'last'));
+ $this->assertSame(array(), $collection->all(), '->remove() accepts an array and can remove multiple routes at once');
+ }
+
public function testSetHost()
{
$collection = new RouteCollection();

0 comments on commit ec69fcb

Please sign in to comment.