Assert CakeException throw when json_encode fails

This commit is contained in:
Rob McVey 2015-03-13 15:52:22 +00:00
parent 8e735c2db0
commit 05aba7afb6

View file

@ -306,4 +306,25 @@ class JsonViewTest extends CakeTestCase {
$this->assertSame($expected, $output);
$this->assertSame('application/javascript', $Response->type());
}
/**
* JsonViewTest::testRenderInvalidJSON()
*
* @expectedException CakeException
* @return void
*/
public function testRenderInvalidJSON() {
$Request = new CakeRequest();
$Response = new CakeResponse();
$Controller = new Controller($Request, $Response);
// non utf-8 stuff
$data = array('data' => array('foo' => 'bar' . chr('0x97')));
$Controller->set($data);
$Controller->set('_serialize', 'data');
$View = new JsonView($Controller);
$output = $View->render();
}
}