public function testHandleSimpleErrorResponse() { $json = '{"rsp": {"stat": "err", "err": {"msg": "Test error", "code": 123}}}'; $response = new Response($json); $this->assertInstanceOf('Rtm\\DataContainer', $response->getResponse()); $this->assertFalse($response->isValid()); $this->assertEquals('Test error', $response->getErrorMessage()); $this->assertEquals('123', $response->getErrorCode()); }
/** * Create response object * @param string $json * @return Response * @throws Rtm\Exception If response is not valid */ public function createResponse($json) { $response = new Response($json); if (false === $response->isValid()) { throw new Exception($response->getErrorMessage(), $response->getErrorCode()); } return $response; }