forked from loafle/openapi-generator-original
add test case for loginUser, separate test cases into different files
This commit is contained in:
@@ -7,8 +7,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
// add a new pet (id 10005) to ensure the pet object is available for all the tests
|
// add a new pet (id 10005) to ensure the pet object is available for all the tests
|
||||||
public static function setUpBeforeClass() {
|
public static function setUpBeforeClass() {
|
||||||
ini_set('display_errors', 1);
|
// for error reporting (need to run with php5.3 to get no warning)
|
||||||
error_reporting(~0);
|
//ini_set('display_errors', 1);
|
||||||
|
//error_reporting(~0);
|
||||||
|
|
||||||
// enable debugging
|
// enable debugging
|
||||||
//SwaggerClient\Configuration::$debug = true;
|
//SwaggerClient\Configuration::$debug = true;
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('SwaggerClient.php');
|
||||||
|
|
||||||
|
class StoreApiTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
// add a new pet (id 10005) to ensure the pet object is available for all the tests
|
||||||
|
public static function setUpBeforeClass() {
|
||||||
|
// for error reporting (need to run with php5.3 to get no warning)
|
||||||
|
//ini_set('display_errors', 1);
|
||||||
|
//error_reporting(~0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test get inventory
|
||||||
|
public function testGetInventory()
|
||||||
|
{
|
||||||
|
// initialize the API client
|
||||||
|
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||||
|
$store_api = new SwaggerClient\StoreAPI($api_client);
|
||||||
|
// get inventory
|
||||||
|
$get_response = $store_api->getInventory();
|
||||||
|
|
||||||
|
$this->assertInternalType("int", $get_response['sold']);
|
||||||
|
$this->assertInternalType("int", $get_response['pending']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('SwaggerClient.php');
|
||||||
|
|
||||||
|
class UserApiTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
// add a new pet (id 10005) to ensure the pet object is available for all the tests
|
||||||
|
public static function setUpBeforeClass() {
|
||||||
|
// for error reporting (need to run with php5.3 to get no warning)
|
||||||
|
//ini_set('display_errors', 1);
|
||||||
|
//error_reporting(~0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test login user
|
||||||
|
public function testLoginUser()
|
||||||
|
{
|
||||||
|
// initialize the API client
|
||||||
|
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||||
|
$user_api = new SwaggerClient\UserAPI($api_client);
|
||||||
|
// login
|
||||||
|
$response = $user_api->loginUser("xxxxx", "yyyyyyyy");
|
||||||
|
|
||||||
|
$this->assertInternalType("string", $response);
|
||||||
|
$this->assertRegExp("/^logged in user session/", $response, "response string starts with 'logged in user session'");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
Reference in New Issue
Block a user