Monday, May 13, 2013

How to test exception renderer with testAction?

My controller actions purposely throw exceptions. These are caught by a custom exception renderer, which outputs the exception as JSON. This is all working correctly in the browser. However, I am trying to write unit tests for these actions, but testAction() throws an exception and does not get rendered by the exception renderer. I've tried setting the 'return' to 'contents' but it still throws the exception. How can I test for the true output of a controller action, with the exceptions caught and rendered the way they would in a browser, under non-test conditions?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: