Matthew Weier O'Phinney-3 wrote:
> 
> 
> Whenever you _forward() or redirect, you should return immediately. As
> an example:
> 
>     if (!$form->isValid($request->getPost())) {
>         return $this->_forward('details');
>     }
> 
> If you don't, the action continues to process. This would definitely
> have an impact on redirects as well.
> 
> 

Thanks.  That fixed some tests, but this one is still giving me trouble:

    public function
testIncorrectLoginRedirectsToHomePageAndDoesNotLogUserIn()
    {        
        $loginCredentials = array('username' => 'member',
                                              'password' => 'wrong',
                                              'redirect' => '');
        $this->request->setMethod('POST')
                              ->setPost($loginCredentials);     
        $this->dispatch('/account/login');

        // Some debugging
        echo $this->response->getBody();
        var_export($this->response->getHeaders());
        
        $this->assertRedirectTo('/');
        $this->assertQueryContentContains('title', 'Home Page');
        $this->assertFalse(Zend_Auth::getInstance()->hasIdentity());
    }

The first assertion passes, but the second fails.  I can see from the
response of getBody() that it's returning the view for the account/login
action, which I didn't intend ever to actually display.  Is that just how it
works, that the response contains the view of the dispatched action whether
or not there's a redirect?  Am I doing the wrong thing by testing the
content of the title tag?

By the way, I fixed the double headers and footers problem I mentioned by
replacing in my setUp function dispatch->('account/logout') with a more
direct Zend_Auth::getInstance()->clearIdentity(), but now I see in some
tests that the response contains JUST the layout and not the view content. 
Is that normal?

-- 
View this message in context: 
http://www.nabble.com/Zend_Test-skipping-over-redirects-tp22821127p22841677.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to