I am at the point where I need to write unit tests for the REST API, written using CakePHP 1.3. The API supports GET, POST, and PUT requests for requests and data processing.
Is there an established way to verify the correct I / O of an API simulating an HTTP request using fixtures ? I do not want to run the actual POST / PUT requests in the live (dev) database. How can I best mock a system to use temporary models, but check the rest of the stack as is?
Testing GET requests is quite simple with controller tests . However, for data processing, the API uses HTTP headers quite widely, and also parses raw XML and JSON POST / PUT data. Unit test controller methods only make fun of POST data by setting $this->data in the controller, which prevents me from testing the API correctly.
api unit-testing cakephp
deceze Jun 28 '10 at 2:55
source share