If you're using the default route, error/error/jg will route successfully to
the error controller's error action. This is why you don't see the
EXCEPTION_NO_CONTROLLER nor EXCEPTION_NO_ACTION errors.

If you look at the default errorAction() method provided by Zend_Tool,
you'll see that it defaults to a 500 error code even if no exception was
thrown.

There is nothing in the error controller that causes an exception to be
thrown if a bad parameter is passed -- you'll need to implement this logic
yourself.

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Wed, Nov 24, 2010 at 9:48 AM, Mike A <[email protected]> wrote:

> 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