codeguy/Slim — Issue #182: Make it easier to test Slim applications
Author: maikg
Created: 2011-10-11 19:28:31+00:00
State: open

I might be missing something, but writing tests for Slim applications is not as straightforward as it could be.

Here's what I did for an application I'm currently working on:

* Stub `Slim_Http_Request` to make `getBody()` return a body string of my choosing (there is no way to override the output of PHP's internal `php://input` stream).
* Stub `Slim` to make `request()` return the stub mentioned above.
* Set a large bunch of `$_SERVER` key/value pairs as most of them are unset when working with the application from the command line (I actually stole this trick from some of Slim's own unit tests).
* Write a test harness that hides all this behind a simple API to perform requests and make assertions on the response.

Is there anything I'm missing and if not, are you open to discussion on how to make testing Slim applications easier?