Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Not an Issue
-
Affects Version/s: 1.7.3
-
Fix Version/s: None
-
Component/s: Zend_Amf
-
Labels:None
-
Tags:
Description
The assertRedirectTo does not work as expected.
Cases:
1. Empty action with redirector, works fine
public function indexAction(){ $this->_helper->redirector('login'); }
2. Action with other code and view renderer, works fine
public function indexAction(){ if( !$this->_request->isPost() ){ $this->_helper->redirector('login'); } // Do other stuff }
3. Action with other multiple redirects aren't broken, unexpected behavior
public function indexAction(){ if( !$this->_request->isPost() ){ $this->_helper->redirector('identify'); } // Do other stuff if( $this->_request->getPost('user_id') ){ $this->_helper->redirector('login'); } else{ $this->_helper->redirector('logout'); } }
In the last case the redirection in the browser goes well, but in the unittest it validates with the last redirection.
When return null; is put below the redirector, the problem is resolved, but it doesn't look like a good solution.
Also the redirectAndExit function causes the unittest to crash.
EDIT
Why can't I find a @# reply button!!
@below: That does resolve the issue. But it's weird that the first redirect does work as expected and with testing it doesn't. I think this should be more clear in the documentation. I can imagine that more people will have problems with this. It's stated in the docs, but not explicitly. (Some examples uses the return).
The primary issue I'm seeing right now is actually in your code. When you call _forward() or one of the _redirect() or redirector methods, you should always return immediately; if you do not do so, the action continues to execute, which can lead to the problems you're describing.
Can you do the following: in each place above where you call $this->_helper->redirector(), change the call to:
and let me know if that corrects the issue.