예제 #1
0
 public static function setUpBeforeClass()
 {
     // for error reporting (need to run with php5.3 to get no warning)
     //ini_set('display_errors', 1);
     //error_reporting(~0);
     // new pet
     $new_pet_id = 10005;
     $new_pet = new Swagger\Client\Model\Pet();
     $new_pet->setId($new_pet_id);
     $new_pet->setName("PHP Unit Test");
     $new_pet->setStatus("available");
     // 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();
     // add a new pet (model)
     $add_response = $pet_api->addPet($new_pet);
 }
예제 #2
0
 public function testGetPetByIdWithByteArray()
 {
     // initialize the API client
     $config = new Swagger\Client\Configuration();
     $config->setHost('http://petstore.swagger.io/v2');
     $api_client = new Swagger\Client\APIClient($config);
     $pet_api = new Swagger\Client\Api\PetAPI($api_client);
     // test getPetByIdWithByteArray
     $pet_id = 10005;
     $bytes = $pet_api->getPetByIdWithByteArray($pet_id);
     $json = json_decode(call_user_func_array('pack', array_merge(array('C*'), $bytes)), true);
     $this->assertInternalType("array", $bytes);
     $this->assertSame($json['id'], $pet_id);
     // not testing name as it's tested by addPetUsingByteArray
     //$this->assertSame($json['name'], 'PHP Unit Test');
     $this->assertSame($json['category']['id'], $pet_id);
     $this->assertSame($json['category']['name'], 'test php category');
     $this->assertSame($json['tags'][0]['id'], $pet_id);
     $this->assertSame($json['tags'][0]['name'], 'test php tag');
 }
예제 #3
0
 public function testUploadFile()
 {
     // initialize the API client
     $config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
     $api_client = new Swagger\Client\ApiClient($config);
     $pet_api = new Swagger\Client\Api\PetAPI($api_client);
     // upload file
     $pet_id = 10001;
     $add_response = $pet_api->uploadFile($pet_id, "test meta", "./composer.json");
     // return nothing (void)
     $this->assertSame($add_response, NULL);
 }