Skip to content

Commit cfa5a55

Browse files
ackintoshwing328
authored andcommitted
[PHP] Improve StoreApiTest (#7141)
* Move the test code to the appropriate test case * currently, InvalidArgumentException will be thrown * Remove unnecessary tests at this time * Unify into single quotes
1 parent 1a831f7 commit cfa5a55

File tree

2 files changed

+13
-38
lines changed

2 files changed

+13
-38
lines changed

samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,17 @@ public function testDefaultValues()
373373
$this->assertSame('red', $animal->getColor());
374374
}
375375

376+
/**
377+
* test invalid argument
378+
*
379+
* @expectedException \InvalidArgumentException
380+
*/
381+
public function testInvalidArgument()
382+
{
383+
// the argument is required, and we must specify one or some from 'available', 'pending', 'sold'
384+
$this->api->findPetsByStatus([]);
385+
}
386+
376387
// Disabled as currently we don't have any endpoint that would return file
377388
// For testing I just replaced url and return type in Api method.
378389
// public function testDownloadingLargeFile()

samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,7 @@ public function testGetInventory()
1818
{
1919
$result = $this->api->getInventory();
2020

21-
$this->assertInternalType("array", $result);
22-
$this->assertInternalType("int", $result['available']);
21+
$this->assertInternalType('array', $result);
22+
$this->assertInternalType('int', $result['available']);
2323
}
24-
25-
/*
26-
* comment out as we've removed invalid endpoints from the spec, we'll introduce something
27-
* similar in the future when we've time to update the petstore server
28-
*
29-
// test get inventory
30-
public function testGetInventoryInObject()
31-
{
32-
$result = $this->api->getInventoryInObject();
33-
34-
$this->assertInternalType("array", $result);
35-
$this->assertInternalType("int", $result['available']);
36-
}
37-
*/
38-
39-
/**
40-
* test empty array response
41-
*
42-
* Make sure empty arrays from a producer is actually returned as
43-
* an empty array and not some other value. At some point it was
44-
* returned as null because the code stumbled on PHP loose type
45-
* checking (not on empty array is true, same thing could happen
46-
* with careless use of empty()).
47-
*/
48-
// public function testEmptyArrayResponse()
49-
// {
50-
// // this call returns and empty array
51-
// $response = $this->api->findPetsByStatus(array());
52-
//
53-
// // make sure this is an array as we want it to be
54-
// $this->assertInternalType("array", $response);
55-
//
56-
// // make sure the array is empty just in case the petstore
57-
// // server changes its output
58-
// $this->assertEmpty($response);
59-
// }
6024
}

0 commit comments

Comments
 (0)