Should I extend the ControllerTestCase and create a custom method to handle this? What is the best way?
Should I extend the ControllerTestCase and create a custom method to handle this? What
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
AJAX response should be no different than any other response. So no subclassing should be necessary.
But if you mean “how to test that the response AJAX request generated from the file I’m testing is correct?” there is no way to do that (except Selenium tests maybe). And it’s not PHP’s job to test this – you should use JavaScript tests to test it.
When you’re sure the AJAX is calling correct URL with correct params, you can create the AJAX request artificaly and test the response as normal request.