Skip to content

Commit

Permalink
[Routing] Added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Pennequin authored and fabpot committed Oct 18, 2010
1 parent c543692 commit 71ace34
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Symfony/Tests/Component/Routing/RouteCollectionTest.php
Expand Up @@ -27,6 +27,17 @@ public function testRoute()
$this->assertNull($collection->getRoute('bar'), '->getRoute() returns null if a route does not exist');
}

/**
* @covers Symfony\Component\Routing\RouteCollection::addRoute
* @expectedException InvalidArgumentException
*/
public function testAddInvalidRoute()
{
$collection = new RouteCollection();
$route = new Route('/foo');
$collection->addRoute('f o o', $route);
}

public function testAddCollection()
{
$collection = new RouteCollection();
Expand Down
13 changes: 13 additions & 0 deletions tests/Symfony/Tests/Component/Routing/RouteTest.php
Expand Up @@ -49,12 +49,25 @@ public function testOptions()
$this->assertEquals($route, $route->setOptions(array()), '->setOptions() implements a fluent interface');
}

/**
* @covers Symfony\Component\Routing\Route::setDefaults
* @covers Symfony\Component\Routing\Route::getDefaults
* @covers Symfony\Component\Routing\Route::setDefault
* @covers Symfony\Component\Routing\Route::getDefault
*/
public function testDefaults()
{
$route = new Route('/:foo');
$route->setDefaults(array('foo' => 'bar'));
$this->assertEquals(array('foo' => 'bar'), $route->getDefaults(), '->setDefaults() sets the defaults');
$this->assertEquals($route, $route->setDefaults(array()), '->setDefaults() implements a fluent interface');

$route->setDefault('foo', 'bar');
$this->assertEquals('bar', $route->getDefault('foo'), '->setDefault() sets a default value');

$route->setDefault('foo2', 'bar2');
$this->assertEquals('bar2', $route->getDefault('foo2'), '->getDefault() return the default value');
$this->assertNull($route->getDefault('not_defined'), '->getDefault() return null if default value is not setted');
}

public function testRequirements()
Expand Down

0 comments on commit 71ace34

Please sign in to comment.