/** * Utility function used to create a new instance from a JSON string. * * @param array $json a PHP array which contains the result of a 'json_decode' execution. * * @return \Gomoob\Pushwoosh\Model\Response\RegisterDeviceResponse the resulting instance. */ public static function create(array $json) { $unregisterDeviceResponse = new UnregisterDeviceResponse(); $unregisterDeviceResponse->setStatusCode($json['status_code']); $unregisterDeviceResponse->setStatusMessage($json['status_message']); return $unregisterDeviceResponse; }
/** * Test method for the <tt>create(array $json)</tt> function. */ public function testCreate() { // Test with a success response $unregisterDeviceResponse = UnregisterDeviceResponse::create(array('status_code' => 200, 'status_message' => 'OK')); $this->assertTrue($unregisterDeviceResponse->isOk()); $this->assertEquals(200, $unregisterDeviceResponse->getStatusCode()); $this->assertEquals('OK', $unregisterDeviceResponse->getStatusMessage()); // Test with an error response $unregisterDeviceResponse = UnregisterDeviceResponse::create(array('status_code' => 400, 'status_message' => 'KO')); $this->assertFalse($unregisterDeviceResponse->isOk()); $this->assertEquals(400, $unregisterDeviceResponse->getStatusCode()); $this->assertEquals('KO', $unregisterDeviceResponse->getStatusMessage()); }