diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php index e091e0ca30d..3fc064a99c2 100644 --- a/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/test/Api/StoreApiTest.php @@ -5,8 +5,7 @@ * * @category Class * @package Swagger\Client - * @author http://github.com/swagger-api/swagger-codegen - * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2 + * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ @@ -18,18 +17,7 @@ * OpenAPI spec version: 1.0.0 * Contact: apiteam@swagger.io * Generated by: https://github.com/swagger-api/swagger-codegen.git - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Swagger Codegen version: 2.3.0-SNAPSHOT */ /** @@ -38,10 +26,9 @@ * Please update the test case below to test the endpoint. */ -namespace Swagger\Client\Api; +namespace Swagger\Client; use \Swagger\Client\Configuration; -use \Swagger\Client\ApiClient; use \Swagger\Client\ApiException; use \Swagger\Client\ObjectSerializer; @@ -50,53 +37,38 @@ use \Swagger\Client\ObjectSerializer; * * @category Class * @package Swagger\Client - * @author http://github.com/swagger-api/swagger-codegen - * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License v2 + * @author Swagger Codegen team * @link https://github.com/swagger-api/swagger-codegen */ class StoreApiTest extends \PHPUnit_Framework_TestCase { /** - * Setup before running each test case + * Setup before running any test cases */ public static function setUpBeforeClass() { - // add a new pet (id 10005) to ensure the pet object is available for all the tests + } - // for error reporting (need to run with php5.3 to get no warning) - //ini_set('display_errors', 1); - //error_reporting(~0); - - // new pet - $new_pet_id = 10005; - $new_pet = new \Swagger\Client\Model\Pet; - $new_pet->setId($new_pet_id); - $new_pet->setName("PHP Unit Test"); - $new_pet->setStatus("available"); - // new tag - $tag= new \Swagger\Client\Model\Tag; - $tag->setId($new_pet_id); // use the same id as pet - $tag->setName("test php tag"); - // new category - $category = new \Swagger\Client\Model\Category; - $category->setId($new_pet_id); // use the same id as pet - $category->setName("test php category"); - - $new_pet->setTags(array($tag)); - $new_pet->setCategory($category); - - $pet_api = new PetApi(); - // add a new pet (model) - $add_response = $pet_api->addPet($new_pet); + /** + * Setup before running each test case + */ + public function setUp() + { } /** * Clean up after running each test case */ + public function tearDown() + { + } + + /** + * Clean up after running all test cases + */ public static function tearDownAfterClass() { - } /** @@ -107,7 +79,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase */ public function testDeleteOrder() { - } /** @@ -118,13 +89,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase */ public function testGetInventory() { - // initialize the API client - $store_api = new StoreApi(); - // get inventory - $get_response = $store_api->getInventory(); - - $this->assertInternalType("array", $get_response); - $this->assertInternalType("int", $get_response['available']); } /** @@ -135,7 +99,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase */ public function testGetOrderById() { - } /** @@ -146,7 +109,5 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase */ public function testPlaceOrder() { - } - } diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php index 4be179c2bc7..3af84b8d851 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/StoreApiTest.php @@ -2,7 +2,11 @@ namespace Swagger\Client; +use Swagger\Client\Api\PetApi; use Swagger\Client\Api\StoreApi; +use Swagger\Client\Model\Category; +use Swagger\Client\Model\Pet; +use Swagger\Client\Model\Tag; class StoreApiTest extends \PHPUnit_Framework_TestCase { @@ -11,7 +15,35 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->api = new Api\StoreApi(); + $this->api = new StoreApi(); + } + + /** + * Setup before running each test case + */ + public static function setUpBeforeClass() + { + // add a new pet (id 10005) to ensure the pet object is available for all the tests + // new pet + $id = 10005; + $pet = new Pet(); + $pet->setId($id); + $pet->setName('PHP Unit Test'); + $pet->setStatus('available'); + // new tag + $tag = new Tag(); + $tag->setId($id); // use the same id as pet + $tag->setName('test php tag'); + // new category + $category = new Category(); + $category->setId($id); // use the same id as pet + $category->setName('test php category'); + + $pet->setTags([$tag]); + $pet->setCategory($category); + + $api = new PetApi(); + $api->addPet($pet); } public function testGetInventory()