Commit c463a6e1 authored by Fabien Potencier's avatar Fabien Potencier

added some unit tests

parent e29c91ed
......@@ -155,4 +155,35 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('mid1', 'mid2', 'mid3'), $controller->getRoute()->getOption('_after_middlewares'));
}
public function testRouteExtension()
{
$route = new MyRoute1();
$controller = new ControllerCollection($route);
$controller->foo('foo');
$this->assertEquals('foo', $route->foo);
}
/**
* @expectedException \BadMethodCallException
*/
public function testRouteMethodDoesNotExist()
{
$route = new MyRoute1();
$controller = new ControllerCollection($route);
$controller->bar();
}
}
class MyRoute1 extends Route
{
public $foo;
public function foo($value)
{
$this->foo = $value;
}
}
......@@ -88,4 +88,35 @@ class ControllerTest extends \PHPUnit_Framework_TestCase
array(new Route('/underscores_and.periods'), '_underscores_and.periods'),
);
}
public function testRouteExtension()
{
$route = new MyRoute();
$controller = new Controller($route);
$controller->foo('foo');
$this->assertEquals('foo', $route->foo);
}
/**
* @expectedException \BadMethodCallException
*/
public function testRouteMethodDoesNotExist()
{
$route = new MyRoute();
$controller = new Controller($route);
$controller->bar();
}
}
class MyRoute extends Route
{
public $foo;
public function foo($value)
{
$this->foo = $value;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment