php add test case for withinfo method returnig void

This commit is contained in:
wing328
2015-12-07 00:30:17 +08:00
parent b282d4fbea
commit 11466570f7
5 changed files with 67 additions and 40 deletions

View File

@@ -108,12 +108,12 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* {{{operationId}}}
* {{{operationId}}}WithHttpInfo
*
* {{{summary}}}
*
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}}
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
{{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
* @throws \{{invokerPackage}}\ApiException on non-2xx response
*/
public function {{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
@@ -209,7 +209,7 @@ use \{{invokerPackage}}\ObjectSerializer;
}
return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader), $statusCode, $httpHeader);
{{/returnType}}{{#returnType}}
{{/returnType}}{{^returnType}}
return array(null, $statusCode, $httpHeader);
{{/returnType}}
} catch (ApiException $e) {

View File

@@ -113,7 +113,7 @@ class PetApi
* Update an existing pet
*
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePetWithHttpInfo ($body=null)
@@ -165,6 +165,8 @@ class PetApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -195,7 +197,7 @@ class PetApi
* Add a new pet to the store
*
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function addPetWithHttpInfo ($body=null)
@@ -247,6 +249,8 @@ class PetApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -277,7 +281,7 @@ class PetApi
* Finds Pets by status
*
* @param string[] $status Status values that need to be considered for filter (optional)
* @return \Swagger\Client\Model\Pet[]
* @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByStatusWithHttpInfo ($status=null)
@@ -334,8 +338,6 @@ class PetApi
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -370,7 +372,7 @@ class PetApi
* Finds Pets by tags
*
* @param string[] $tags Tags to filter by (optional)
* @return \Swagger\Client\Model\Pet[]
* @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByTagsWithHttpInfo ($tags=null)
@@ -427,8 +429,6 @@ class PetApi
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -463,7 +463,7 @@ class PetApi
* Find pet by ID
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return \Swagger\Client\Model\Pet
* @return Array of \Swagger\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getPetByIdWithHttpInfo ($pet_id)
@@ -530,8 +530,6 @@ class PetApi
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -570,7 +568,7 @@ class PetApi
* @param string $pet_id ID of pet that needs to be updated (required)
* @param string $name Updated name of the pet (optional)
* @param string $status Updated status of the pet (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePetWithFormWithHttpInfo ($pet_id, $name=null, $status=null)
@@ -641,6 +639,8 @@ class PetApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -673,7 +673,7 @@ class PetApi
*
* @param int $pet_id Pet id to delete (required)
* @param string $api_key (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deletePetWithHttpInfo ($pet_id, $api_key=null)
@@ -735,6 +735,8 @@ class PetApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -769,7 +771,7 @@ class PetApi
* @param int $pet_id ID of pet to update (required)
* @param string $additional_metadata Additional data to pass to server (optional)
* @param \SplFileObject $file file to upload (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function uploadFileWithHttpInfo ($pet_id, $additional_metadata=null, $file=null)
@@ -846,6 +848,8 @@ class PetApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}

View File

@@ -111,7 +111,7 @@ class StoreApi
*
* Returns pet inventories by status
*
* @return map[string,int]
* @return Array of map[string,int], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getInventoryWithHttpInfo ()
@@ -167,8 +167,6 @@ class StoreApi
return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -203,7 +201,7 @@ class StoreApi
* Place an order for a pet
*
* @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional)
* @return \Swagger\Client\Model\Order
* @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function placeOrderWithHttpInfo ($body=null)
@@ -256,8 +254,6 @@ class StoreApi
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -292,7 +288,7 @@ class StoreApi
* Find purchase order by ID
*
* @param string $order_id ID of pet that needs to be fetched (required)
* @return \Swagger\Client\Model\Order
* @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getOrderByIdWithHttpInfo ($order_id)
@@ -352,8 +348,6 @@ class StoreApi
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -388,7 +382,7 @@ class StoreApi
* Delete purchase order by ID
*
* @param string $order_id ID of the order that needs to be deleted (required)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteOrderWithHttpInfo ($order_id)
@@ -442,6 +436,8 @@ class StoreApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}

View File

@@ -113,7 +113,7 @@ class UserApi
* Create user
*
* @param \Swagger\Client\Model\User $body Created user object (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUserWithHttpInfo ($body=null)
@@ -160,6 +160,8 @@ class UserApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -190,7 +192,7 @@ class UserApi
* Creates list of users with given input array
*
* @param \Swagger\Client\Model\User[] $body List of user object (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithArrayInputWithHttpInfo ($body=null)
@@ -237,6 +239,8 @@ class UserApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -267,7 +271,7 @@ class UserApi
* Creates list of users with given input array
*
* @param \Swagger\Client\Model\User[] $body List of user object (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithListInputWithHttpInfo ($body=null)
@@ -314,6 +318,8 @@ class UserApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -346,7 +352,7 @@ class UserApi
*
* @param string $username The user name for login (optional)
* @param string $password The password for login in clear text (optional)
* @return string
* @return Array of string, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function loginUserWithHttpInfo ($username=null, $password=null)
@@ -401,8 +407,6 @@ class UserApi
return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -435,7 +439,7 @@ class UserApi
*
* Logs out current logged in user session
*
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function logoutUserWithHttpInfo ()
@@ -478,6 +482,8 @@ class UserApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -508,7 +514,7 @@ class UserApi
* Get user by user name
*
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
* @return \Swagger\Client\Model\User
* @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getUserByNameWithHttpInfo ($username)
@@ -568,8 +574,6 @@ class UserApi
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
@@ -606,7 +610,7 @@ class UserApi
*
* @param string $username name that need to be deleted (required)
* @param \Swagger\Client\Model\User $body Updated user object (optional)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updateUserWithHttpInfo ($username, $body=null)
@@ -664,6 +668,8 @@ class UserApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
@@ -694,7 +700,7 @@ class UserApi
* Delete user
*
* @param string $username The name that needs to be deleted (required)
* @return void
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteUserWithHttpInfo ($username)
@@ -748,6 +754,8 @@ class UserApi
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}

View File

@@ -168,7 +168,26 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
$this->assertSame($response->getName(), 'updatePet');
}
// test updatePet and verify by the "id" of the response
// test updatePetWithFormWithHttpInfo and verify by the "name" of the response
public function testUpdatePetWithFormWithHttpInfo()
{
// initialize the API client
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
$api_client = new Swagger\Client\ApiClient($config);
$pet_id = 10001; // ID of pet that needs to be fetched
$pet_api = new Swagger\Client\Api\PetAPI($api_client);
// update Pet (form)
list($update_response, $status_code, $http_headers) = $pet_api->updatePetWithFormWithHttpInfo($pet_id, 'update pet with form with http info');
// return nothing (void)
$this->assertNull($update_response);
$this->assertSame($status_code, 200);
$this->assertSame($http_headers['Content-Type'], 'application/json');
$response = $pet_api->getPetById($pet_id);
$this->assertSame($response->getId(), $pet_id);
$this->assertSame($response->getName(), 'update pet with form with http info');
}
// test updatePetWithForm and verify by the "name" and "status" of the response
public function testUpdatePetWithForm()
{
// initialize the API client