Fixed PSR request parsing, broken after recent changes

This commit is contained in:
Vladimir Razuvaev 2018-01-13 18:08:07 +07:00
parent 918bbff2bd
commit 4f223ba11d
2 changed files with 2 additions and 8 deletions

View File

@ -499,12 +499,6 @@ class Helper
Utils::printSafeJson($bodyParams)
);
}
if (empty($bodyParams)) {
throw new InvariantViolation(
"PSR-7 request is expected to provide parsed body for \"application/json\" requests but got empty array"
);
}
} else {
$bodyParams = $request->getParsedBody();

View File

@ -177,12 +177,12 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
public function testFailsParsingNonPreParsedPsrRequest()
{
try {
$this->parsePsrRequest('application/json', json_encode([]));
$this->parsePsrRequest('application/json', json_encode(null));
$this->fail('Expected exception not thrown');
} catch (InvariantViolation $e) {
// Expecting parsing exception to be thrown somewhere else:
$this->assertEquals(
'PSR-7 request is expected to provide parsed body for "application/json" requests but got empty array',
'PSR-7 request is expected to provide parsed body for "application/json" requests but got null',
$e->getMessage()
);
}