Browsing articles from "January, 2011"
Jan
15

Unit Testing your AJAX requests with Zend Framework and PHPunit

I ran into a problem yesterday, when trying to create a couple of unit tests using PHPunit along side the Zend Framework.

If you want to unit test an action in a controller that checks the request to see if is an XML HTTP Request using the isXmlHttpRequest() method provided by the Zend Framework, then you will definitely run into a problem.

isXmlHttpRequest() pretty much checks to see if the $_SERVER['HTTP_X_REQUESTED_WITH'] is set with ‘XMLHttpRequest’, if not, then returns FALSE. I thought that by setting the server variable with XMLHttpRequest directly will allow me to bypass the check.
read more