I'm using Zend-Framework and PHP-Unit.
MY SETUP
I have a html form:
<form method="post" action="/my-module/my-controller/do">
<input type="text" name="var" value="my value" />
<input type="submit" value="sumit" />
</form>
This is the equivalent unit test:
public function test_myForm ()
{
$this->request->setMethod('POST')->setPost(array(
'var' => 'my value'
));
$this->dispatch('/my-module/my-controller/do');
}
The controller action looks like this (for testing purpose):
public function doAction ()
{
print_r($_POST);
echo "\n -------------------- \n";
print_r(file_get_contents('php://input'));
echo "\n -------------------- \n";
die;
}
THE RESULTS
If I submit the form on the browser I get this result:
Array ( [var] => my value )
--------------------
var=my+value
--------------------
But if do the unit test, this is the output:
Array ( [var] => my value )
--------------------
--------------------
MY QUESTION
The code "file_get_contents('php://input')" returns an empty string I don't know why.
For the application I'm working on, it is important to read the post data like this "file_get_contents('php://input')" and not just use $_POST.
Anyone an idea why this happens and how to solve it?