Matthias Klein
Matthias Klein

Reputation: 31

Zend Framework Unittest: How to render response on redirect()

I have a lot of $this->redirect() in my controllers, issuing a Zend_Flashmessage and then redirecting. Due to the fact, that Zend_Test is disabling responses on redirect, I can't see an opportunity to verify my flash messages.

Is there a way to call the render() function in my unittest to verify the output?

Upvotes: 3

Views: 240

Answers (1)

user217782
user217782

Reputation:

Do you really need to test that Zend Framework controller is working like it should? Or could you make your test case more specific by verifying that ->redirect() is called once, and that your flash message has been set (next paragraph). That way, you're trusting that Zend Controller will show the flash message, because that functionality is already tested by Zend.

I would recommend simply writing and calling a ->redirectWithMessage() method, that you can easily mock and verify. Leaving Zend functionality out of the test.

Upvotes: 1

Related Questions