Exemple #1
0
 protected function setUp()
 {
     $this->data = array('user' => array('id' => 1, 'first_name' => 'foo', 'posts' => array(1, 5, 8)));
     $this->errorMessage = 'error';
     $this->errorCode = 42;
     $this->success = JSendResponse::success();
     $this->successWithData = JSendResponse::success($this->data);
     $this->fail = JSendResponse::fail();
     $this->failWithData = JSendResponse::fail($this->data);
     $this->error = JSendResponse::error($this->errorMessage);
     $this->errorWithData = JSendResponse::error($this->errorMessage, $this->errorCode, $this->data);
 }
 public function testAddingEncodeOptions()
 {
     $success = JSendResponse::success(array('some' => 'data'));
     $success->setEncodingOptions(\JSON_PRETTY_PRINT);
     $result = $success->encode();
     $pretty = json_encode($success->asArray(), \JSON_PRETTY_PRINT);
     $this->assertEquals($pretty, $result);
 }