/**
  * 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\GetTagsResponse the resulting instance.
  */
 public static function create(array $json)
 {
     $getTagsResponse = new GetTagsResponse();
     $getTagsResponse->setStatusCode($json['status_code']);
     $getTagsResponse->setStatusMessage($json['status_message']);
     // If a 'response' is provided
     if (array_key_exists('response', $json) && isset($json['response'])) {
         $getTagsResponseResponse = new GetTagsResponseResponse();
         // If a 'result' is provided
         if (array_key_exists('result', $json['response'])) {
             $getTagsResponseResponse->setResult($json['response']['result']);
         }
         $getTagsResponse->setResponse($getTagsResponseResponse);
     }
     return $getTagsResponse;
 }
 /**
  * Test method for the <tt>create(array $json)</tt> function.
  */
 public function testCreate()
 {
     // Test with a successful response
     $getTagsResponse = GetTagsResponse::create(array('status_code' => 200, 'status_message' => 'OK', 'response' => array('result' => array('tag0' => 'tag0Value', 'tag1' => 'tag1Value', 'tag2' => 'tag2Value'))));
     $getTagsResponseResponse = $getTagsResponse->getResponse();
     $this->assertNotNull($getTagsResponseResponse);
     $result = $getTagsResponseResponse->getResult();
     $this->assertCount(3, $result);
     $this->assertEquals('tag0Value', $result['tag0']);
     $this->assertEquals('tag1Value', $result['tag1']);
     $this->assertEquals('tag2Value', $result['tag2']);
     $tags = $getTagsResponseResponse->getTags();
     $this->assertCount(3, $tags);
     $this->assertEquals('tag0Value', $tags['tag0']);
     $this->assertEquals('tag1Value', $tags['tag1']);
     $this->assertEquals('tag2Value', $tags['tag2']);
     $this->assertTrue($getTagsResponseResponse->hasTag('tag0'));
     $this->assertTrue($getTagsResponseResponse->hasTag('tag1'));
     $this->assertTrue($getTagsResponseResponse->hasTag('tag2'));
     $this->assertTrue($getTagsResponse->isOk());
     $this->assertEquals(200, $getTagsResponse->getStatusCode());
     $this->assertEquals('OK', $getTagsResponse->getStatusMessage());
     // Test with an error response without any 'response' field
     $getTagsResponse = GetTagsResponse::create(array('status_code' => 400, 'status_message' => 'KO'));
     $getTagsResponseResponse = $getTagsResponse->getResponse();
     $this->assertNull($getTagsResponseResponse);
     $this->assertFalse($getTagsResponse->isOk());
     $this->assertEquals(400, $getTagsResponse->getStatusCode());
     $this->assertEquals('KO', $getTagsResponse->getStatusMessage());
     // Test with an error response with a null 'response' field
     // Fix https://github.com/gomoob/php-pushwoosh/issues/13
     $getTagsResponse = GetTagsResponse::create(array('status_code' => 400, 'status_message' => 'KO', 'response' => null));
     $getTagsResponseResponse = $getTagsResponse->getResponse();
     $this->assertNull($getTagsResponseResponse);
     $this->assertFalse($getTagsResponse->isOk());
     $this->assertEquals(400, $getTagsResponse->getStatusCode());
     $this->assertEquals('KO', $getTagsResponse->getStatusMessage());
 }