Skip to content

Commit

Permalink
Assert CakeException throw when json_encode fails
Browse files Browse the repository at this point in the history
  • Loading branch information
robmcvey committed Mar 13, 2015
1 parent 8e735c2 commit 05aba7a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/Cake/Test/Case/View/JsonViewTest.php
Expand Up @@ -306,4 +306,25 @@ public function testRenderWithViewAndNamed() {
$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();
}

}

0 comments on commit 05aba7a

Please sign in to comment.