Example #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);
     // when running with php5.5, comment out below to skip the warning about
     // using @ to handle file upload
     //ini_set('display_startup_errors',1);
     //ini_set('display_errors',1);
     //error_reporting(-1);
     // enable debugging
     //Swagger\Client\Configuration::$debug = true;
     // skip initializing the API client as it should be automatic
     //$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
     // 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 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);
 }
 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);
 }
Example #3
0
 //$pet_api = new Swagger\Client\PetAPI($api_client);
 $pet_api = new Swagger\Client\Api\PetApi();
 $pet_api->getApiClient()->getConfig()->setTempFolderPath('/var/tmp/php/');
 // test default header
 //$pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903");
 // return Pet (model)
 $response = $pet_api->getPetById($petId);
 // to test __toString()
 print $response;
 // add pet (post json)
 $new_pet_id = 10005;
 $new_pet = new Swagger\Client\Model\Pet();
 $new_pet->setId($new_pet_id);
 $new_pet->setName("PHP Unit Test");
 // new tag
 $tag = new Swagger\Client\Model\Tag();
 $tag->setId($new_pet_id);
 // use the same id as pet
 //$tag->name = "test php tag";
 // new category
 $category = new Swagger\Client\Model\Category();
 $category->setId(10005);
 // use the same id as pet
 //$category->name = "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);
 // test upload file (should return exception)
 $upload_response = $pet_api->uploadFile($petId, "test meta", NULL);
 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');
 }
$new_pet_id = 50001;
// ID of pet that needs to be fetched
for ($x = 0; $x <= $counter; $x++) {
    try {
        prof_flag("{$x}: NEW PETAPI");
        $pet_api = new Swagger\Client\Api\PetApi();
        // ~~~ ADD PET ~~~
        prof_flag("{$x}: ADD PET");
        // add pet (post json)
        $new_pet = new Swagger\Client\Model\Pet();
        $new_pet->setId($new_pet_id);
        $new_pet->setName("profiler");
        $new_pet->setStatus("available");
        $new_pet->setPhotoUrls(array("http://profiler.com"));
        // new tag
        $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);