Merge pull request #1832 from wing328/php_array_test

[PHP] add more test case for php (array of array, map of map)
This commit is contained in:
wing328 2016-01-08 14:39:23 +08:00
commit c993b2bd70
8 changed files with 155 additions and 69 deletions

View File

@ -199,11 +199,11 @@ class ObjectSerializer
* *
* @param mixed $data object or primitive to be deserialized * @param mixed $data object or primitive to be deserialized
* @param string $class class name is passed as a string * @param string $class class name is passed as a string
* @param string $httpHeader HTTP headers * @param string $httpHeaders HTTP headers
* *
* @return object an instance of $class * @return object an instance of $class
*/ */
public function deserialize($data, $class, $httpHeader=null) public function deserialize($data, $class, $httpHeaders=null)
{ {
if (null === $data) { if (null === $data) {
$deserialized = null; $deserialized = null;
@ -231,7 +231,7 @@ class ObjectSerializer
$deserialized = $data; $deserialized = $data;
} elseif ($class === '\SplFileObject') { } elseif ($class === '\SplFileObject') {
// determine file name // determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) { if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1]; $filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
} else { } else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');

View File

@ -126,8 +126,6 @@ use \{{invokerPackage}}\ObjectSerializer;
// parse inputs // parse inputs
$resourcePath = "{{path}}"; $resourcePath = "{{path}}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "{{httpMethod}}";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -169,6 +167,9 @@ use \{{invokerPackage}}\ObjectSerializer;
$resourcePath $resourcePath
); );
}{{/pathParams}} }{{/pathParams}}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
{{#formParams}}// form params {{#formParams}}// form params
if (${{paramName}} !== null) { if (${{paramName}} !== null) {
{{#isFile}} {{#isFile}}
@ -213,7 +214,7 @@ use \{{invokerPackage}}\ObjectSerializer;
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, '{{httpMethod}}',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams{{#returnType}}, '{{returnType}}'{{/returnType}} $headerParams{{#returnType}}, '{{returnType}}'{{/returnType}}
); );

View File

@ -72,6 +72,11 @@ public class PetApiTest {
} }
@Test @Test
@Ignore
/* ignoring the findPetByTags test below as it's very similar to
* testFindPetsByStatus and testFindPetsByTags sometimes got 500
* due to server issue, which makes the test unstable.
*/
public void testFindPetsByTags() throws Exception { public void testFindPetsByTags() throws Exception {
Pet pet = createRandomPet(); Pet pet = createRandomPet();
pet.setName("monster"); pet.setName("monster");

View File

@ -122,8 +122,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet"; $resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -137,6 +135,9 @@ class PetApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params // body params
$_tempBody = null; $_tempBody = null;
@ -159,7 +160,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'PUT',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -205,8 +206,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet"; $resourcePath = "/pet";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -220,6 +219,9 @@ class PetApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params // body params
$_tempBody = null; $_tempBody = null;
@ -242,7 +244,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'POST',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -288,8 +290,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet/findByStatus"; $resourcePath = "/pet/findByStatus";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -311,6 +311,9 @@ class PetApi
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -329,7 +332,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]' $headerParams, '\Swagger\Client\Model\Pet[]'
); );
@ -383,8 +386,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet/findByTags"; $resourcePath = "/pet/findByTags";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -406,6 +407,9 @@ class PetApi
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -424,7 +428,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]' $headerParams, '\Swagger\Client\Model\Pet[]'
); );
@ -482,8 +486,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -505,6 +507,9 @@ class PetApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -525,7 +530,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet' $headerParams, '\Swagger\Client\Model\Pet'
); );
@ -587,8 +592,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -610,6 +613,9 @@ class PetApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// form params // form params
if ($name !== null) { if ($name !== null) {
@ -640,7 +646,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'POST',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -692,8 +698,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}"; $resourcePath = "/pet/{petId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -719,6 +723,9 @@ class PetApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -737,7 +744,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'DELETE',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -791,8 +798,6 @@ class PetApi
// parse inputs // parse inputs
$resourcePath = "/pet/{petId}/uploadImage"; $resourcePath = "/pet/{petId}/uploadImage";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -814,6 +819,9 @@ class PetApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// form params // form params
if ($additional_metadata !== null) { if ($additional_metadata !== null) {
@ -850,7 +858,7 @@ class PetApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'POST',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );

View File

@ -120,8 +120,6 @@ class StoreApi
// parse inputs // parse inputs
$resourcePath = "/store/inventory"; $resourcePath = "/store/inventory";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -135,6 +133,9 @@ class StoreApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -155,7 +156,7 @@ class StoreApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, 'map[string,int]' $headerParams, 'map[string,int]'
); );
@ -209,8 +210,6 @@ class StoreApi
// parse inputs // parse inputs
$resourcePath = "/store/order"; $resourcePath = "/store/order";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -224,6 +223,9 @@ class StoreApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params // body params
$_tempBody = null; $_tempBody = null;
@ -241,7 +243,7 @@ class StoreApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'POST',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order' $headerParams, '\Swagger\Client\Model\Order'
); );
@ -299,8 +301,6 @@ class StoreApi
// parse inputs // parse inputs
$resourcePath = "/store/order/{orderId}"; $resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -322,6 +322,9 @@ class StoreApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -335,7 +338,7 @@ class StoreApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order' $headerParams, '\Swagger\Client\Model\Order'
); );
@ -393,8 +396,6 @@ class StoreApi
// parse inputs // parse inputs
$resourcePath = "/store/order/{orderId}"; $resourcePath = "/store/order/{orderId}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -416,6 +417,9 @@ class StoreApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -429,7 +433,7 @@ class StoreApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'DELETE',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );

View File

@ -122,8 +122,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user"; $resourcePath = "/user";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -137,6 +135,9 @@ class UserApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params // body params
$_tempBody = null; $_tempBody = null;
@ -154,7 +155,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'POST',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -200,8 +201,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user/createWithArray"; $resourcePath = "/user/createWithArray";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -215,6 +214,9 @@ class UserApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params // body params
$_tempBody = null; $_tempBody = null;
@ -232,7 +234,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'POST',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -278,8 +280,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user/createWithList"; $resourcePath = "/user/createWithList";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -293,6 +293,9 @@ class UserApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params // body params
$_tempBody = null; $_tempBody = null;
@ -310,7 +313,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'POST',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -358,8 +361,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user/login"; $resourcePath = "/user/login";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -381,6 +382,9 @@ class UserApi
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -394,7 +398,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, 'string' $headerParams, 'string'
); );
@ -446,8 +450,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user/logout"; $resourcePath = "/user/logout";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -461,6 +463,9 @@ class UserApi
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -474,7 +479,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -524,8 +529,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -547,6 +550,9 @@ class UserApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -560,7 +566,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'GET',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\User' $headerParams, '\Swagger\Client\Model\User'
); );
@ -620,8 +626,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -643,6 +647,9 @@ class UserApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params // body params
$_tempBody = null; $_tempBody = null;
@ -660,7 +667,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'PUT',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
@ -710,8 +717,6 @@ class UserApi
// parse inputs // parse inputs
$resourcePath = "/user/{username}"; $resourcePath = "/user/{username}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "DELETE";
$httpBody = ''; $httpBody = '';
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
@ -733,6 +738,9 @@ class UserApi
$resourcePath $resourcePath
); );
} }
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
@ -746,7 +754,7 @@ class UserApi
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, 'DELETE',
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );

View File

@ -199,11 +199,11 @@ class ObjectSerializer
* *
* @param mixed $data object or primitive to be deserialized * @param mixed $data object or primitive to be deserialized
* @param string $class class name is passed as a string * @param string $class class name is passed as a string
* @param string $httpHeader HTTP headers * @param string $httpHeaders HTTP headers
* *
* @return object an instance of $class * @return object an instance of $class
*/ */
public function deserialize($data, $class, $httpHeader=null) public function deserialize($data, $class, $httpHeaders=null)
{ {
if (null === $data) { if (null === $data) {
$deserialized = null; $deserialized = null;
@ -231,7 +231,7 @@ class ObjectSerializer
$deserialized = $data; $deserialized = $data;
} elseif ($class === '\SplFileObject') { } elseif ($class === '\SplFileObject') {
// determine file name // determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) { if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1]; $filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
} else { } else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');

View File

@ -57,6 +57,66 @@ ORDER;
$this->assertSame(false, $order->getComplete()); $this->assertSame(false, $order->getComplete());
} }
// test deseralization of array of array of order
public function testDeserializationOfArrayOfArrayOfOrder()
{
$order_json = <<<ORDER
[[{
"id": 10,
"petId": 20,
"quantity": 30,
"shipDate": "2015-08-22T07:13:36.613Z",
"status": "placed",
"complete": false
}]]
ORDER;
$serializer = new Swagger\Client\ObjectSerializer;
$order = $serializer->deserialize(json_decode($order_json), 'Swagger\Client\Model\Order[][]');
$this->assertArrayHasKey(0, $order);
$this->assertArrayHasKey(0, $order[0]);
$_order = $order[0][0];
$this->assertInstanceOf('Swagger\Client\Model\Order', $_order);
$this->assertSame(10, $_order->getId());
$this->assertSame(20, $_order->getPetId());
$this->assertSame(30, $_order->getQuantity());
$this->assertTrue(new DateTime("2015-08-22T07:13:36.613Z") == $_order->getShipDate());
$this->assertSame("placed", $_order->getStatus());
$this->assertSame(false, $_order->getComplete());
}
// test deseralization of map of map of order
public function testDeserializationOfMapOfMapOfOrder()
{
$order_json = <<<ORDER
{
"test": {
"test2": {
"id": 10,
"petId": 20,
"quantity": 30,
"shipDate": "2015-08-22T07:13:36.613Z",
"status": "placed",
"complete": false
}
}
}
ORDER;
$serializer = new Swagger\Client\ObjectSerializer;
$order = $serializer->deserialize(json_decode($order_json), 'map[string,map[string,\Swagger\Client\Model\Order]]');
$this->assertArrayHasKey('test', $order);
$this->assertArrayHasKey('test2', $order['test']);
$_order = $order['test']['test2'];
$this->assertInstanceOf('Swagger\Client\Model\Order', $_order);
$this->assertSame(10, $_order->getId());
$this->assertSame(20, $_order->getPetId());
$this->assertSame(30, $_order->getQuantity());
$this->assertTrue(new DateTime("2015-08-22T07:13:36.613Z") == $_order->getShipDate());
$this->assertSame("placed", $_order->getStatus());
$this->assertSame(false, $_order->getComplete());
}
} }
?> ?>