down votefavorite
<http://stackoverflow.com/questions/36000402/testing-ajax-calls-in-cakephp-2-8#>
I'm working with Cake 2.8.1. I've installed PHPUnit and am writing unit
tests for my app. However, I've run into a problem when trying to test AJAX
calls.
My application checks to make sure that the request is an AJAX call and
throws a NotFoundException if is isn't.
if (!$this->request->is('ajax')) {
throw new NotFoundException(__('Illegal url call'));}
I can write tests that catch the exception, but I'm struggling to create
tests for valid inputs and calls. When I run them, the test suite for that
controller just stops and doesn't show any more input. The testing results
summation that is usually present at the bottom doesn't appear and any
tests following that one are not run. I've seen this solution
<http://stackoverflow.com/questions/8182278/testing-ajax-request-in-cakephp-2-0>
in
several different answers. I've tried setting both the $_ENV and $_SERVER
variables and neither seems to help.
I tried digging into the testing code in Cake itself, but I got lost pretty
quickly. Does anyone have suggestions for how to debug this and/or write
correct unit tests? Thanks!
--
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
We will soon be closing this Google Group. But don't worry, we have something
better coming. Stay tuned for an updated from the CakePHP Team soon.
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow 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 [email protected].
For more options, visit https://groups.google.com/d/optout.