Caporegime
I have a PHP method (from my controller class):
That I need to unit test - but I'm not sure how.. The Router is a mock actor as that hasn't been implemented yet. It will return null on 'success' or a new instance of itself on failure (ergo, a new route.) The mock object simply returns a new instance (well, the same instance actually..) on the first iteration, and null on the second.
I'm not sure how or where I can squeeze in an assert/expect to test?
Any suggestions welcome
Code:
function execute ($route = null)
{
do
{
$route = $this->getRouter()->execute($route);
} while (!is_null($route));
}
That I need to unit test - but I'm not sure how.. The Router is a mock actor as that hasn't been implemented yet. It will return null on 'success' or a new instance of itself on failure (ergo, a new route.) The mock object simply returns a new instance (well, the same instance actually..) on the first iteration, and null on the second.
Code:
Mock::generate('Router');
$router = new MockRouter;
$router->setReturnValueAt(0, 'execute', $router);
$router->setReturnValueAt(1, 'execute', null);
$controller->setRouter($router);
I'm not sure how or where I can squeeze in an assert/expect to test?
Any suggestions welcome