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.
Today I wanted to write about 5 awesome Zend Framework components/helpers that can help you when working with ajax.
This handy little method can eliminate the need to send extra parameters such as /ajax/true/ to let the controller know it’s an Ajax request. read more