Moved on a bit with this. A bit confused, though, about the $this->response->isException() flag and output under some conditions of $this->getRequest()->getParam('error_handler')->type.

Example unit test for ErrorController...

public function testX() {
    $this->dispatch('/error/error/jg');

echo "Response exception (boolean): ".$this->response->isException()."\n";
    echo "Response code: ". $this->response->getHttpResponseCode()."\n";
echo "Exception dump:".var_dump($this->getRequest()->getParam('error_handler')->type)."\n";
}

If I set dispatch to provide a bad controller or action I get isException flagged as boolean "1" and corresponding getHttpResponseCode() and error handler type. For a bad controller the values are "404" and "EXCEPTION_NO_CONTROLLER", and for a bad action the same HttpResponseCode and "EXCEPTION_NO_ACTION".

If in dispatch I set correct controller and action but a bad parameter, as in the above example unit test, I receive the expected HttpResponseCode (500) but null values for isException and the error_handler type. Why is this?


On 23/11/2010 20:26, Mike A wrote:
After 8pm here, suspect my two brain cells have given up, but have to set up a walking skeleton...

I want to write a unit test to check two items.

1) The different error handler messages (like Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER); and 2) the HTTP error codes.

For an ErrorController action exception...
public function testX() {
    $this->dispatch('/error/xxx');

    ...
}

How to get the error_handler result? In ErrorController it starts with $errors = $this->_getParam('error_handler');

A practical example or pointer to one would be appreciated.

TIA...

Mike A.



Reply via email to