Exemplo n.º 1
0
 /**
  * test empty array response
  *
  * Make sure empty arrays from a producer is actually returned as
  * an empty array and not some other value. At some point it was
  * returned as null because the code stumbled on PHP loose type
  * checking (not on empty array is true, same thing could happen
  * with careless use of empty()).
  */
 public function testEmptyArrayResponse()
 {
     // initialize the API client
     $config = (new Configuration())->setHost('http://petstore.swagger.io/v2');
     $apiClient = new ApiClient($config);
     $storeApi = new Api\PetApi($apiClient);
     // this call returns and empty array
     $response = $storeApi->findPetsByStatus(array());
     // make sure this is an array as we want it to be
     $this->assertInternalType("array", $response);
     // make sure the array is empty just in case the petstore
     // server changes its output
     $this->assertEmpty($response);
 }
Exemplo n.º 2
0
 public function testFindPetByStatus()
 {
     // initialize the API client
     $config = (new Configuration())->setHost('http://petstore.swagger.io/v2');
     $api_client = new ApiClient($config);
     $pet_api = new Api\PetApi($api_client);
     // return Pet (model)
     $response = $pet_api->findPetsByStatus("available");
     $this->assertGreaterThan(0, count($response));
     // at least one object returned
     $this->assertSame(get_class($response[0]), "Swagger\\Client\\Model\\Pet");
     // verify the object is Pet
     // loop through result to ensure status is "available"
     foreach ($response as $_pet) {
         $this->assertSame($_pet['status'], "available");
     }
     // test invalid status
     $response = $pet_api->findPetsByStatus("unknown_and_incorrect_status");
     $this->assertSame(count($response), 0);
     // confirm no object returned
 }