Hi,
I have a problem that makes TDD with Zend_Test impossible and I don't
know with which release this problem was introduced and how to solve it.
Think of a test case like this:
----------------------------------------------------------------------------------
class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function testShowArticle()
{
$this->dispatch('/index/show/id/2');
$this->assertController('index');
$this->assertAction('show');
$this->assertEquals('2', $this->request->getParam('id'));
$this->assertRoute('default');
}
}
----------------------------------------------------------------------------------
And now lets presume that the IndexController exists but the
showAction() is not available yet due to the TDD approach. When I run
PHPUnit for this test case I only get this error:
----------------------------------------------------------------------------------
1) testShowArticle(IndexControllerTest)
Failed asserting last controller used was "index"
/home/devhost/phpmagazin/tdd3/library/Zend/Test/PHPUnit/ControllerTestCase.php:931
/home/devhost/phpmagazin/tdd3/tests/controllers/IndexControllerTest.php:41
----------------------------------------------------------------------------------
I would expect that the line with the dispatch() call throws an error
telling me that the showAction() method does not exist in
IndexController class. But it doesn't. With a little investigation I
found out that the ErrorHandler handles this error and moves the action
to ErrorController::errorAction().
What am I doing wrong? Should I deactivate the ErrorHandler for all test
cases? Or is there a better approach?
Thanks and best regards,
Ralf