2008年11月25日星期二

Re: [fw-mvc] Zend_Test_PHPUnit - assertRedirectTo failing

-- afx114 <jsnodspam@gmail.com> wrote
(on Tuesday, 25 November 2008, 06:06 PM -0800):
> And here is my unit test:
>
> public function testCallWithoutActionShouldForwardToLoginAction()
> {
> $this->dispatch('/auth');
> //$this->assertRedirect(); // this test passes
> $this->assertRedirectTo('/auth/login'); // this test fails
> }
>
>
> Note that if I use $this->assertRedirect(), the unit test passes. It is
> only when I use assertRedirectTo() that it fails. Any ideas? I've been
> racking my brain on this for hours... Thx in advance. :)

Use this as the assertion -- it'll give you more information:

$this->assertRedirectTo('/auth/login', var_export($this->response->getHeaders()));

That should show you what headers were actually set in the response
object, and may give more insight into why the test is failing.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: