/**
  * 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\CreateMessageResponse the resulting instance.
  */
 public static function create(array $json)
 {
     $createMessageResponse = new CreateMessageResponse();
     $createMessageResponse->setStatusCode($json['status_code']);
     $createMessageResponse->setStatusMessage($json['status_message']);
     // If a 'response' is provided
     if (array_key_exists('response', $json) && isset($json['response'])) {
         $createMessageResponseResponse = new CreateMessageResponseResponse();
         // If 'Messages' are provided
         if (array_key_exists('Messages', $json['response'])) {
             $createMessageResponseResponse->setMessages($json['response']['Messages']);
         }
         $createMessageResponse->setResponse($createMessageResponseResponse);
     }
     return $createMessageResponse;
 }
 /**
  * Test method for the <tt>create(array $json)</tt> function.
  */
 public function testCreate()
 {
     // Test with a successful response
     $createMessageResponse = CreateMessageResponse::create(array('status_code' => 200, 'status_message' => 'OK', 'response' => array('Messages' => array('notificationCode0', 'notificationCode1', 'notificationCode2'))));
     $createMessageResponseResponse = $createMessageResponse->getResponse();
     $this->assertNotNull($createMessageResponseResponse);
     $messages = $createMessageResponseResponse->getMessages();
     $this->assertCount(3, $messages);
     $this->assertTrue(in_array('notificationCode0', $messages));
     $this->assertTrue(in_array('notificationCode1', $messages));
     $this->assertTrue(in_array('notificationCode2', $messages));
     $this->assertTrue($createMessageResponse->isOk());
     $this->assertEquals(200, $createMessageResponse->getStatusCode());
     $this->assertEquals('OK', $createMessageResponse->getStatusMessage());
     // Test with an error response without any 'response' field
     $createMessageResponse = CreateMessageResponse::create(array('status_code' => 400, 'status_message' => 'KO'));
     $createMessageResponseResponse = $createMessageResponse->getResponse();
     $this->assertNull($createMessageResponseResponse);
     $this->assertFalse($createMessageResponse->isOk());
     $this->assertEquals(400, $createMessageResponse->getStatusCode());
     $this->assertEquals('KO', $createMessageResponse->getStatusMessage());
     // Test with an error response with a null 'response' field
     // Fix https://github.com/gomoob/php-pushwoosh/issues/13
     $createMessageResponse = CreateMessageResponse::create(array('status_code' => 400, 'status_message' => 'KO', 'response' => null));
     $createMessageResponseResponse = $createMessageResponse->getResponse();
     $this->assertNull($createMessageResponseResponse);
     $this->assertFalse($createMessageResponse->isOk());
     $this->assertEquals(400, $createMessageResponse->getStatusCode());
     $this->assertEquals('KO', $createMessageResponse->getStatusMessage());
 }