I’m trying to write a unit test for a controller using Zend and PHPUnit
In the code I get data from php://input
$req = new Zend_Controller_Request_Http();
$data = $req->getRawBody();
My code works fine when I test the real application, but unless I can supply data as a raw http post, $data will always be blank. The getRawBody() method basically calls file_get_contents(‘php://input’), but how do I override this in order to supply the test data to my application.
Provided the
$req->getRawBody()is, as you say, the same asfile_get_contents('php://input')…Not a perfect solution, but similar to what I have used in the past when designing scripts to handle piped emails with great success.