php - Problem testing exceptions with PHPUnit and Zend Framework -
when user accesses /user/validate without correct post parameters, zend application throws zend exception. (i standard "an error occurred" message, framed within layout). intentional.
i trying test behaviour phpunit. here's test:
/** * @expectedexception zend_exception */ public function testemptyuservalidationparameterscauseexception() { $this->dispatch('/user/validate'); }
when run test message saying failed, "expected exception zend_exception". ideas?
i have other tests in file working fine...
thanks!
the zend_controller_plugin_errorhandler plugin handles exceptions , default error_controller forces 500 redirect may mean exception testing no longer exists. try following unit test , see if passes:
public function testunknownuserredirectstoerrorpage() { $this->dispatch('/user/validate'); $this->assertcontroller('error'); $this->assertaction('error'); $this->assertresponsecode('500'); }
if works shows time rendering error view exception no longer exist contained in code before redirect.
Comments
Post a Comment