From 576306816b472bdccea779ca80be78d7faf47dd9 Mon Sep 17 00:00:00 2001 From: "akihito.nakano" Date: Sat, 9 Dec 2017 10:48:20 +0900 Subject: [PATCH 1/4] Move the test code to the appropriate test case --- .../SwaggerClient-php/tests/PetApiTest.php | 22 +++++++++++++++++++ .../SwaggerClient-php/tests/StoreApiTest.php | 22 ------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index c29b6d2686f..acd15670d79 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -373,6 +373,28 @@ public function testDefaultValues() $this->assertSame('red', $animal->getColor()); } + /** + * 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() + { + // this call returns and empty array + $response = $this->api->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); + } + // Disabled as currently we don't have any endpoint that would return file // For testing I just replaced url and return type in Api method. // public function testDownloadingLargeFile() diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php index f413737461c..8f48ad86697 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php @@ -35,26 +35,4 @@ public function testGetInventoryInObject() $this->assertInternalType("int", $result['available']); } */ - - /** - * 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() -// { -// // this call returns and empty array -// $response = $this->api->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); -// } } From 88c28d7cd785fa3e23b3ee9d91b64111771381be Mon Sep 17 00:00:00 2001 From: "akihito.nakano" Date: Sat, 9 Dec 2017 10:53:53 +0900 Subject: [PATCH 2/4] currently, InvalidArgumentException will be thrown --- .../SwaggerClient-php/tests/PetApiTest.php | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index acd15670d79..500b03896a0 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -374,25 +374,14 @@ public function testDefaultValues() } /** - * test empty array response + * test invalid argument * - * 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()). + * @expectedException \InvalidArgumentException */ - public function testEmptyArrayResponse() + public function testInvalidArgument() { - // this call returns and empty array - $response = $this->api->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); + // the argument is required, and we must specify one or some from 'available', 'pending', 'sold' + $this->api->findPetsByStatus([]); } // Disabled as currently we don't have any endpoint that would return file From 065663073ef897f67850941813640561b968a0a9 Mon Sep 17 00:00:00 2001 From: "akihito.nakano" Date: Sat, 9 Dec 2017 11:10:10 +0900 Subject: [PATCH 3/4] Remove unnecessary tests at this time --- .../php/SwaggerClient-php/tests/StoreApiTest.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php index 8f48ad86697..8f5405c9d7e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php @@ -21,18 +21,4 @@ public function testGetInventory() $this->assertInternalType("array", $result); $this->assertInternalType("int", $result['available']); } - - /* - * comment out as we've removed invalid endpoints from the spec, we'll introduce something - * similar in the future when we've time to update the petstore server - * - // test get inventory - public function testGetInventoryInObject() - { - $result = $this->api->getInventoryInObject(); - - $this->assertInternalType("array", $result); - $this->assertInternalType("int", $result['available']); - } - */ } From 27ca438fdb475b7ab1c3458dfdf59e3352a3a0e3 Mon Sep 17 00:00:00 2001 From: "akihito.nakano" Date: Sat, 9 Dec 2017 11:13:22 +0900 Subject: [PATCH 4/4] Unify into single quotes --- .../petstore/php/SwaggerClient-php/tests/StoreApiTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php index 8f5405c9d7e..4be179c2bc7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php @@ -18,7 +18,7 @@ public function testGetInventory() { $result = $this->api->getInventory(); - $this->assertInternalType("array", $result); - $this->assertInternalType("int", $result['available']); + $this->assertInternalType('array', $result); + $this->assertInternalType('int', $result['available']); } }