Zend_Test_PHPUnit_ControllerTestCase not throwing response exceptions?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Test_PHPUnit_ControllerTestCase not throwing response exceptions?

Marian Meres-2
Hello Everyone,

I'm playing with the Zend_Test_PHPUnit_ControllerTestCase and have run
into a behavior which is somewhat different from what I'm used to with
"plain" phpunit testing.

This is what I have:

class MyControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
    public function testSome()
    {
        $this->dispatch('/some');
        $this->assertModule('some');
    }
}

Now if "/some" throws exception all I see is: Failed asserting last
module used <"default"> was "some"

I would expect notifying me about the thrown exception right away, as
it took me a while to track it down...

Is this the expected behavior?

Thank you in advance,
M.
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Test_PHPUnit_ControllerTestCase not throwing response exceptions?

Marian Meres-2
Just an answer to myself: yes, exceptions are not throwing, it is a feature.

@see Zend_Test_PHPUnit_ControllerTestCase::dispatch()

m.

On Tue, Apr 6, 2010 at 5:06 PM, Marian Meres <[hidden email]> wrote:

> Hello Everyone,
>
> I'm playing with the Zend_Test_PHPUnit_ControllerTestCase and have run
> into a behavior which is somewhat different from what I'm used to with
> "plain" phpunit testing.
>
> This is what I have:
>
> class MyControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
> {
>    public function testSome()
>    {
>        $this->dispatch('/some');
>        $this->assertModule('some');
>    }
> }
>
> Now if "/some" throws exception all I see is: Failed asserting last
> module used <"default"> was "some"
>
> I would expect notifying me about the thrown exception right away, as
> it took me a while to track it down...
>
> Is this the expected behavior?
>
> Thank you in advance,
> M.
>
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Test_PHPUnit_ControllerTestCase not throwing response exceptions?

Hector Virgen
There's an open bug for this, and it seems a patch was provided to add a second argument to dispatch() that would allow you to specify if exceptions should be thrown.

But it seems the current workaround would be to pull the exception from the response object.

--
Hector


On Tue, Apr 6, 2010 at 9:10 AM, Marian Meres <[hidden email]> wrote:
Just an answer to myself: yes, exceptions are not throwing, it is a feature.

@see Zend_Test_PHPUnit_ControllerTestCase::dispatch()

m.

On Tue, Apr 6, 2010 at 5:06 PM, Marian Meres <[hidden email]> wrote:
> Hello Everyone,
>
> I'm playing with the Zend_Test_PHPUnit_ControllerTestCase and have run
> into a behavior which is somewhat different from what I'm used to with
> "plain" phpunit testing.
>
> This is what I have:
>
> class MyControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
> {
>    public function testSome()
>    {
>        $this->dispatch('/some');
>        $this->assertModule('some');
>    }
> }
>
> Now if "/some" throws exception all I see is: Failed asserting last
> module used <"default"> was "some"
>
> I would expect notifying me about the thrown exception right away, as
> it took me a while to track it down...
>
> Is this the expected behavior?
>
> Thank you in advance,
> M.
>

--
Hector Virgen