add test case for api client instance

This commit is contained in:
wing328
2015-05-23 10:35:19 +08:00
parent 612abf134b
commit 691838c47d
7 changed files with 129 additions and 17 deletions

View File

@@ -92,15 +92,36 @@ class APIClient {
}
/**
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
* get the user agent of the api client
*
* @return string user agent
*/
public function getUserAgent($user_agent) {
return $this->user_agent;
}
/**
* set the HTTP timeout value
*
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
*/
public function setTimeout($seconds) {
if (!is_numeric($seconds))
throw new \InvalidArgumentException('Timeout variable must be numeric.');
if (!is_numeric($seconds) || $seconds < 0)
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
$this->curl_timeout = $seconds;
}
/**
* get the HTTP timeout value
*
* @return string HTTP timeout value
*/
public function getTimeout() {
return $this->curl_timeout;
}
/**
* Get API key (with prefix if set)
* @param string key name

View File

@@ -24,7 +24,6 @@ namespace SwaggerClient;
class PetApi {
function __construct($apiClient = null) {
if (null === $apiClient) {
if (Configuration::$apiClient === null) {
@@ -38,8 +37,7 @@ class PetApi {
}
}
private $apiClient;
private $apiClient; // instance of the APIClient
/**
* get the API client
@@ -51,10 +49,11 @@ class PetApi {
/**
* set the API client
*/
public function getApiClient($apiClient) {
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* updatePet
*

View File

@@ -37,6 +37,22 @@ class StoreApi {
}
}
private $apiClient; // instance of the APIClient
/**
* get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* getInventory

View File

@@ -37,6 +37,22 @@ class UserApi {
}
}
private $apiClient; // instance of the APIClient
/**
* get the API client
*/
public function getApiClient() {
return $this->apiClient;
}
/**
* set the API client
*/
public function setApiClient($apiClient) {
$this->apiClient = $apiClient;
}
/**
* createUser