Example #1
0
 public function testUploadFile()
 {
     // initialize the API client
     $api_client = new SwaggerClient\ApiClient('http://petstore.swagger.io/v2');
     $pet_api = new SwaggerClient\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);
 }
Example #2
0
    // return Pet (model)
    $response = $pet_api->getPetById($petId);
    var_dump($response);
    // test upload file (exception)
    $upload_response = $pet_api->uploadFile($petId, "test meta", NULL);
    // add pet (post json)
    $new_pet_id = 10005;
    $new_pet = new SwaggerClient\models\Pet();
    $new_pet->id = $new_pet_id;
    $new_pet->name = "PHP Unit Test";
    // new tag
    $tag = new SwaggerClient\models\Tag();
    $tag->id = $new_pet_id;
    // use the same id as pet
    //$tag->name = "test php tag";
    // new category
    $category = new SwaggerClient\models\Category();
    $category->id = 0;
    // use the same id as pet
    //$category->name = "test php category";
    $new_pet->tags = array($tag);
    $new_pet->category = $category;
    $pet_api = new SwaggerClient\PetAPI();
    // add a new pet (model)
    $add_response = $pet_api->addPet($new_pet);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    echo 'HTTP response headers: ', $e->getResponseHeaders(), "\n";
    echo 'HTTP response body: ', $e->getResponseBody(), "\n";
    echo 'HTTP status code: ', $e->getCode(), "\n";
}