|
|
@ -61,4 +61,49 @@ class RouterTest extends PHPUnit_Framework_TestCase |
|
|
|
$router->setDefaultLayout('userLayout'); |
|
|
|
$this->assertAttributeEquals('userLayout', 'default_layout', $router); |
|
|
|
} |
|
|
|
|
|
|
|
public function testGetRouteWithNameIsNull() |
|
|
|
{ |
|
|
|
$name = null; |
|
|
|
$route = 'route object.'; |
|
|
|
$router = new Router(); |
|
|
|
$reflection = new ReflectionProperty('Router', 'route'); |
|
|
|
$reflection->setAccessible(true); |
|
|
|
$reflection->setValue($router, $route); |
|
|
|
$this->assertEquals($route, $router->getRoute($name)); |
|
|
|
} |
|
|
|
|
|
|
|
public function testGetRouteWithNamed() |
|
|
|
{ |
|
|
|
$name = 'nameofroute'; |
|
|
|
$uri = 'uri from route.'; |
|
|
|
$route = 'route object.'; |
|
|
|
$router = new Router(); |
|
|
|
$reflection = new ReflectionProperty('Router', 'routes'); |
|
|
|
$reflection->setAccessible(true); |
|
|
|
$reflection->setValue($router, array($name => $route)); |
|
|
|
$this->assertEquals($route, $router->getRoute($name)); |
|
|
|
} |
|
|
|
|
|
|
|
public function testGetRouteWithNamedWithError() |
|
|
|
{ |
|
|
|
$name = 'name of route'; |
|
|
|
$router = new Router(); |
|
|
|
$this->setExpectedException('ErrorException'); |
|
|
|
$router->getRoute($name); |
|
|
|
} |
|
|
|
|
|
|
|
public function testRouteIsExists() |
|
|
|
{ |
|
|
|
$route = 'route object.'; |
|
|
|
$name = 'nameofroute'; |
|
|
|
$name_is_not_exists = 'nameofroutenotexists'; |
|
|
|
$routes = array($name => $route); |
|
|
|
$router = new Router(); |
|
|
|
$reflection = new ReflectionProperty('Router', 'routes'); |
|
|
|
$reflection->setAccessible(true); |
|
|
|
$reflection->setValue($router, $routes); |
|
|
|
$this->assertTrue($router->routeIsExists($name)); |
|
|
|
$this->assertFalse($router->routeIsExists($name_is_not_exists)); |
|
|
|
} |
|
|
|
} |