public function testAutomaticContentDecoding()
{
foreach (array('POST', 'PUT', 'PATCH') as $method) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, '{ "foo": "bar" }');
rewind($stream);
$request = new Request(compact('stream') + array('env' => array('CONTENT_TYPE' => 'application/json; charset=UTF-8', 'REQUEST_METHOD' => $method)));
$this->assertEqual(array('foo' => 'bar'), $request->data);
}
foreach (array('GET', 'HEAD', 'OPTIONS', 'DELETE') as $method) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, '{ "foo": "bar" }');
rewind($stream);
$request = new Request(compact('stream') + array('env' => array('CONTENT_TYPE' => 'application/json; charset=UTF-8', 'REQUEST_METHOD' => $method)));
$this->assertEmpty($request->data);
}
}