Clear json_last_error

This commit is contained in:
Jérôme Tamarelle 2014-09-15 23:11:34 +02:00 committed by Fabien Potencier
parent ef91f710e3
commit 6d6a3af4ff
2 changed files with 6 additions and 2 deletions

View File

@ -107,6 +107,9 @@ class JsonResponse extends Response
});
try {
// Clear json_last_error()
json_encode(null);
$this->data = json_encode($data, $this->encodingOptions);
restore_error_handler();

View File

@ -203,8 +203,9 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedExceptionMessage This error is expected
* @expectedException Exception
* @expectedExceptionMessage Failed calling Symfony\Component\HttpFoundation\Tests\JsonSerializableObject::jsonSerialize()
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php#114688
*/
public function testSetContentJsonSerializeError()
{