public function testAddPetUsingByteArray() { // initialize the API client $config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2'); $api_client = new Swagger\Client\ApiClient($config); $new_pet_id = 10005; $new_pet = new Swagger\Client\Model\Pet(); $new_pet->setId($new_pet_id); $new_pet->setName("PHP Unit Test 3"); // new tag $tag = new Swagger\Client\Model\Tag(); $tag->setId($new_pet_id); // use the same id as pet $tag->setName("test php tag"); // new category $category = new Swagger\Client\Model\Category(); $category->setId($new_pet_id); // use the same id as pet $category->setName("test php category"); $new_pet->setTags(array($tag)); $new_pet->setCategory($category); $pet_api = new Swagger\Client\Api\PetAPI($api_client); // add a new pet (model) $object_serializer = new Swagger\Client\ObjectSerializer(); $pet_json_string = json_encode($object_serializer->sanitizeForSerialization($new_pet)); $add_response = $pet_api->addPetUsingByteArray(unpack('C*', $pet_json_string)); // return nothing (void) $this->assertSame($add_response, NULL); // verify added Pet $response = $pet_api->getPetById($new_pet_id); $this->assertSame($response->getId(), $new_pet_id); $this->assertSame($response->getName(), 'PHP Unit Test 3'); }