Exemple #1
0
 public function testUpdatePetWithForm()
 {
     // initialize the API client
     $config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
     $api_client = new Swagger\Client\ApiClient($config);
     $pet_id = 10001;
     // ID of pet that needs to be fetched
     $pet_api = new Swagger\Client\Api\PetApi($api_client);
     // update Pet (form)
     $update_response = $pet_api->updatePetWithForm($pet_id, 'update pet with form', 'sold');
     // return nothing (void)
     $this->assertSame($update_response, NULL);
     $response = $pet_api->getPetById($pet_id);
     $this->assertSame($response->getId(), $pet_id);
     $this->assertSame($response->getName(), 'update pet with form');
     $this->assertSame($response->getStatus(), 'sold');
 }
        $tag = new Swagger\Client\Model\Tag();
        $tag->setId($new_pet_id);
        // use the same id as pet
        $tag->setName("profile tag 1");
        // new category
        $category = new Swagger\Client\Model\Category();
        $category->setId($new_pet_id);
        // use the same id as pet
        $category->setName("profile category 1");
        $new_pet->setTags(array($tag));
        $new_pet->setCategory($category);
        // add a new pet (model)
        $add_response = $pet_api->addPet($new_pet);
        // ~~~ GET PET ~~~
        prof_flag("{$x}: GET PET");
        $response = $pet_api->getPetById($new_pet_id);
        // ~~~ UPDATE PET WITH FORM ~~~
        prof_flag("{$x}: UPDATE PET");
        $response = $pet_api->updatePetWithForm($new_pet_id, "new profiler", "sold");
        // ~~~ DELETE PET ~~~
        prof_flag("{$x}: DELETE PET");
        $response = $pet_api->deletePet($new_pet_id);
    } catch (Swagger\Client\ApiException $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
        echo 'HTTP response headers: ', print_r($e->getResponseHeaders(), true), "\n";
        echo 'HTTP response body: ', print_r($e->getResponseBody(), true), "\n";
        echo 'HTTP status code: ', $e->getCode(), "\n";
    }
}
prof_flag("{$x}: FINISH");
prof_print();