diff --git a/bin/php-petstore.sh b/bin/php-petstore.sh index e1b58239aa5..daf07978aab 100755 --- a/bin/php-petstore.sh +++ b/bin/php-petstore.sh @@ -3,4 +3,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export CLASSPATH="$DIR/../target/lib/*:$DIR/../target/*" export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/petstore/php/PHPPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key +scala $WORDNIK_OPTS $JAVA_CONFIG_OPTIONS -cp $CLASSPATH "$@" samples/client/petstore/php/PHPPetstoreCodegen.scala http://petstore.swagger.wordnik.com/api/resources.json special-key diff --git a/samples/petstore/php/PHPPetstoreCodegen.scala b/samples/client/petstore/php/PHPPetstoreCodegen.scala similarity index 85% rename from samples/petstore/php/PHPPetstoreCodegen.scala rename to samples/client/petstore/php/PHPPetstoreCodegen.scala index 1b498a067d0..61854dff6e8 100644 --- a/samples/petstore/php/PHPPetstoreCodegen.scala +++ b/samples/client/petstore/php/PHPPetstoreCodegen.scala @@ -7,7 +7,7 @@ import java.io.File object PHPPetstoreCodegen extends BasicPHPGenerator { def main(args: Array[String]) = generateClient(args) - override def destinationDir = "samples/petstore/php" + override def destinationDir = "samples/client/petstore/php" override def supportingFiles = List( ("Swagger.mustache", destinationDir + File.separator + apiPackage.get, "Swagger.php") diff --git a/samples/petstore/php/petstore/PetApi.php b/samples/client/petstore/php/PetApi.php similarity index 100% rename from samples/petstore/php/petstore/PetApi.php rename to samples/client/petstore/php/PetApi.php diff --git a/samples/petstore/php/petstore/StoreApi.php b/samples/client/petstore/php/StoreApi.php similarity index 100% rename from samples/petstore/php/petstore/StoreApi.php rename to samples/client/petstore/php/StoreApi.php diff --git a/samples/petstore/php/petstore/Swagger.php b/samples/client/petstore/php/Swagger.php similarity index 100% rename from samples/petstore/php/petstore/Swagger.php rename to samples/client/petstore/php/Swagger.php diff --git a/samples/petstore/php/petstore/UserApi.php b/samples/client/petstore/php/UserApi.php similarity index 100% rename from samples/petstore/php/petstore/UserApi.php rename to samples/client/petstore/php/UserApi.php diff --git a/samples/petstore/php/petstore/models/Category.php b/samples/client/petstore/php/models/Category.php similarity index 100% rename from samples/petstore/php/petstore/models/Category.php rename to samples/client/petstore/php/models/Category.php diff --git a/samples/petstore/php/petstore/models/Order.php b/samples/client/petstore/php/models/Order.php similarity index 100% rename from samples/petstore/php/petstore/models/Order.php rename to samples/client/petstore/php/models/Order.php diff --git a/samples/petstore/php/petstore/models/Pet.php b/samples/client/petstore/php/models/Pet.php similarity index 100% rename from samples/petstore/php/petstore/models/Pet.php rename to samples/client/petstore/php/models/Pet.php diff --git a/samples/petstore/php/petstore/models/Tag.php b/samples/client/petstore/php/models/Tag.php similarity index 100% rename from samples/petstore/php/petstore/models/Tag.php rename to samples/client/petstore/php/models/Tag.php diff --git a/samples/petstore/php/petstore/models/User.php b/samples/client/petstore/php/models/User.php similarity index 100% rename from samples/petstore/php/petstore/models/User.php rename to samples/client/petstore/php/models/User.php diff --git a/samples/petstore/php/README.md b/samples/petstore/php/README.md deleted file mode 100644 index 144868f0651..00000000000 --- a/samples/petstore/php/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Sample Petstore PHP application - -Here's a PHP 5 [Swagger](http://swagger.wordnik.com/) client for the Petstore -sample application. See the interactive Swagger documentation at -http://petstore.swagger.wordnik.com/ for more information on this -demonstration API. - -The client contained in ```petstore``` was generated using this -```swagger-codegen``` project, with the following command: - - ./bin/runscala.sh com.wordnik.swagger.codegen.BasicPHPGenerator http://petstore.swagger.wordnik.com/api/resources.json special-key - -To run the tests, you will need -[PHPUnit](https://github.com/sebastianbergmann/phpunit) installed on your -system. With the ```phpunit``` command in your path, run the tests for each -resource as follows: - - phpunit tests/PetApiTest.php - phpunit tests/StoreApiTest.php - phpunit tests/UserApiTest.php \ No newline at end of file diff --git a/samples/petstore/php/tests/BaseApiTest.php b/samples/petstore/php/tests/BaseApiTest.php deleted file mode 100644 index ba9cc4d01c1..00000000000 --- a/samples/petstore/php/tests/BaseApiTest.php +++ /dev/null @@ -1,50 +0,0 @@ -apiKey = "special-key"; - $this->apiUrl = "http://petstore.swagger.wordnik.com/api"; - $this->username = "test"; - $this->password = "test"; - $this->client = new APIClient($this->apiKey, $this->apiUrl); - $this->petApi = new PetApi($this->client); - $this->storeApi = new StoreApi($this->client); - $this->userApi = new UserApi($this->client); - } - - public function tearDown() { - unset($this->client); - } - -} - - -?> \ No newline at end of file diff --git a/samples/petstore/php/tests/PetApiTest.php b/samples/petstore/php/tests/PetApiTest.php deleted file mode 100644 index 2d3b3ec130e..00000000000 --- a/samples/petstore/php/tests/PetApiTest.php +++ /dev/null @@ -1,123 +0,0 @@ -assertEquals(3, count($doc->apis)); - } - - public function testPetApisWithKey() { - $ch = curl_init("http://petstore.swagger.wordnik.com/api/pet.json?api_key=special-key"); - if (! $ch) { - die("No php curl handle"); - } - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - - $data = curl_exec($ch); - $doc = json_decode($data); - - $this->assertEquals(4, count($doc->apis)); - } - - public function testGetPetById() { - $res = $this->petApi->getPetById(1); - $this->assertEquals($res->id, 1); - } - - public function testAddPet() { - $pet = new Pet(); - $pet->id = self::$randomId; - $tag1 = new Tag(); - $tag1->name = "tag1"; - $tag2 = new Tag(); - $tag2->name = "some tag"; - $pet->tags = array($tag1, $tag2); - $category = new Category(); - $category->name = "Cats"; - $pet->category = $category; - $pet->status = "sold"; - $pet->name = "Shermie"; - $pet->photoUrls = array("http://foo.com/1.jpg", "http://foo.com/1.jpg"); - $res = $this->petApi->addPet($pet); - - $new_pet = $this->petApi->getPetById($pet->id); - - $this->assertEquals($new_pet->id, $pet->id); - $this->assertEquals($new_pet->name, $pet->name); - $this->assertEquals($new_pet->tags, $pet->tags); - $this->assertEquals($new_pet->status, $pet->status); - $this->assertEquals($new_pet->category, $pet->category); - $this->assertEquals($new_pet->photoUrls, $pet->photoUrls); - } - - public function testUpdatePet() { - $pet = new Pet(); - $pet->id = self::$randomId; - $tag1 = new Tag(); - $tag1->name = rand(10000, 100000); - $tag2 = new Tag(); - $tag2->name = "special-tag"; - $pet->tags = array($tag1, $tag2); - $category = new Category(); - $category->name = rand(10000, 100000); - $pet->category = $category; - $pet->status = "sold"; - $pet->name = rand(10000, 100000); - $pet->photoUrls = array(rand(10000, 100000), rand(10000, 100000)); - $res = $this->petApi->updatePet($pet); - - $updated_pet = $this->petApi->getPetById($pet->id); - - $this->assertEquals($updated_pet->id, $pet->id); - $this->assertEquals($updated_pet->name, $pet->name); - $this->assertEquals($updated_pet->tags, $pet->tags); - $this->assertEquals($updated_pet->status, $pet->status); - $this->assertEquals($updated_pet->category, $pet->category); - $this->assertEquals($updated_pet->photoUrls, $pet->photoUrls); } - - public function testFindPetsByTags() { - $res = $this->petApi->findPetsByTags("special-tag"); - $tag_found = false; - foreach ($res as $found_pet) { - if ($found_pet->id == self::$randomId) { - $tag_found = true; - } - } - $this->assertEquals(true, $tag_found); - } - - public function testFindPetsByStatus() { - $res = $this->petApi->findPetsByStatus("sold"); - $tag_found = false; - foreach ($res as $found_pet) { - if ($found_pet->id == self::$randomId) { - $tag_found = true; - } - } - $this->assertEquals(true, $tag_found); - } - - - - -} -?> \ No newline at end of file diff --git a/samples/petstore/php/tests/StoreApiTest.php b/samples/petstore/php/tests/StoreApiTest.php deleted file mode 100644 index a1db91de9d4..00000000000 --- a/samples/petstore/php/tests/StoreApiTest.php +++ /dev/null @@ -1,42 +0,0 @@ -storeApi->getOrderById(1); - $this->assertEquals(1, $res->petId); - $this->assertEquals('DateTime', get_class($res->shipDate)); - } - - public function testDeleteOrder() { - $res = $this->storeApi->deleteOrder(3); - $res = $this->storeApi->deleteOrder("foo"); - - // We just want to make sure there are no errors in this test. - // To verify you are getting back a 200, you might want to add - // something like this to Swagger.php callAPI(): - // print "Response for call to $resourcePath : "; - // print_r($data); - } - - public function testPlaceOrder() { - $order = new Order(); - - $order->petId = 1; - $order->status = "ordered"; - $order->quantity = 10; - // $order->shipDate = "1/1/2013"; - - $res = $this->storeApi->placeOrder($order); - - // We just want to make sure there are no errors in this test. - // To verify you are getting back a 200, you might want to add - // something like this to Swagger.php callAPI(): - // print "Response for call to $resourcePath : "; - // print_r($data); - } - -} -?> \ No newline at end of file diff --git a/samples/petstore/php/tests/UserApiTest.php b/samples/petstore/php/tests/UserApiTest.php deleted file mode 100644 index d9a454b34b2..00000000000 --- a/samples/petstore/php/tests/UserApiTest.php +++ /dev/null @@ -1,220 +0,0 @@ -id = rand(10000, 100000); - $user->lastName = rand(10000, 100000); - $user->username = self::$randomUsername1; - $user->phone = rand(10000, 100000); - $user->email = rand(10000, 100000); - $user->userStatus = rand(10000, 100000); - $user->firstName = rand(10000, 100000); - $user->password = rand(10000, 100000); - - $otherUser = new User(); - - $otherUser->id = rand(10000, 100000); - $otherUser->lastName = rand(10000, 100000); - $otherUser->username = self::$randomUsername2; - $otherUser->phone = rand(10000, 100000); - $otherUser->email = rand(10000, 100000); - $otherUser->userStatus = rand(10000, 100000); - $otherUser->firstName = rand(10000, 100000); - $otherUser->password = rand(10000, 100000); - - $users = array($user, $otherUser); - $res = $this->userApi->createUsersWithArrayInput($users); - - $new_user = $this->userApi->getUserByName(self::$randomUsername1); - - $this->assertEquals($new_user->id, $user->id); - $this->assertEquals($new_user->lastName, $user->lastName); - $this->assertEquals($new_user->username, $user->username); - $this->assertEquals($new_user->phone, $user->phone); - $this->assertEquals($new_user->email, $user->email); - $this->assertEquals($new_user->userStatus, $user->userStatus); - $this->assertEquals($new_user->firstName, $user->firstName); - $this->assertEquals($new_user->password, $user->password); - - $new_user = $this->userApi->getUserByName(self::$randomUsername2); - - $this->assertEquals($new_user->id, $otherUser->id); - $this->assertEquals($new_user->lastName, $otherUser->lastName); - $this->assertEquals($new_user->username, $otherUser->username); - $this->assertEquals($new_user->phone, $otherUser->phone); - $this->assertEquals($new_user->email, $otherUser->email); - $this->assertEquals($new_user->userStatus, $otherUser->userStatus); - $this->assertEquals($new_user->firstName, $otherUser->firstName); - $this->assertEquals($new_user->password, $otherUser->password); - - } - - public function testCreateUsersWithListInput() { - - $user = new User(); - - $user->id = rand(10000, 100000); - $user->lastName = rand(10000, 100000); - $user->username = self::$randomUsername4; - $user->phone = rand(10000, 100000); - $user->email = rand(10000, 100000); - $user->userStatus = rand(10000, 100000); - $user->firstName = rand(10000, 100000); - $user->password = rand(10000, 100000); - - $otherUser = new User(); - - $otherUser->id = rand(10000, 100000); - $otherUser->lastName = rand(10000, 100000); - $otherUser->username = self::$randomUsername5; - $otherUser->phone = rand(10000, 100000); - $otherUser->email = rand(10000, 100000); - $otherUser->userStatus = rand(10000, 100000); - $otherUser->firstName = rand(10000, 100000); - $otherUser->password = rand(10000, 100000); - - $users = array($user, $otherUser); - $res = $this->userApi->createUsersWithArrayInput($users); - - $new_user = $this->userApi->getUserByName(self::$randomUsername4); - - $this->assertEquals($new_user->id, $user->id); - $this->assertEquals($new_user->lastName, $user->lastName); - $this->assertEquals($new_user->username, $user->username); - $this->assertEquals($new_user->phone, $user->phone); - $this->assertEquals($new_user->email, $user->email); - $this->assertEquals($new_user->userStatus, $user->userStatus); - $this->assertEquals($new_user->firstName, $user->firstName); - $this->assertEquals($new_user->password, $user->password); - - $new_user = $this->userApi->getUserByName(self::$randomUsername5); - - $this->assertEquals($new_user->id, $otherUser->id); - $this->assertEquals($new_user->lastName, $otherUser->lastName); - $this->assertEquals($new_user->username, $otherUser->username); - $this->assertEquals($new_user->phone, $otherUser->phone); - $this->assertEquals($new_user->email, $otherUser->email); - $this->assertEquals($new_user->userStatus, $otherUser->userStatus); - $this->assertEquals($new_user->firstName, $otherUser->firstName); - $this->assertEquals($new_user->password, $otherUser->password); - - } - - public function testCreateUser() { - - $user = new User(); - - $user->id = rand(10000, 100000); - $user->lastName = rand(10000, 100000); - $user->username = self::$randomUsername3; - $user->phone = rand(10000, 100000); - $user->email = rand(10000, 100000); - $user->userStatus = rand(10000, 100000); - $user->firstName = rand(10000, 100000); - $user->password = rand(10000, 100000); - - $res = $this->userApi->createUser($user); - - $new_user = $this->userApi->getUserByName(self::$randomUsername3); - - $this->assertEquals($new_user->id, $user->id); - $this->assertEquals($new_user->lastName, $user->lastName); - $this->assertEquals($new_user->username, $user->username); - $this->assertEquals($new_user->phone, $user->phone); - $this->assertEquals($new_user->email, $user->email); - $this->assertEquals($new_user->userStatus, $user->userStatus); - $this->assertEquals($new_user->firstName, $user->firstName); - $this->assertEquals($new_user->password, $user->password); - - } - - public function testUpdateUser() { - - $user = $this->userApi->getUserByName(self::$randomUsername1); - - $user->lastName = rand(10000, 100000); - $user->phone = rand(10000, 100000); - $user->email = rand(10000, 100000); - $user->userStatus = rand(10000, 100000); - $user->firstName = rand(10000, 100000); - $user->password = rand(10000, 100000); - - $res = $this->userApi->updateUser(self::$randomUsername1, $user); - - $updated_user = $this->userApi->getUserByName(self::$randomUsername1); - - $this->assertEquals($updated_user->lastName, $user->lastName); - $this->assertEquals($updated_user->username, $user->username); - $this->assertEquals($updated_user->phone, $user->phone); - $this->assertEquals($updated_user->email, $user->email); - $this->assertEquals($updated_user->userStatus, $user->userStatus); - $this->assertEquals($updated_user->firstName, $user->firstName); - $this->assertEquals($updated_user->password, $user->password); - - } - - public function testDeleteUser() { - - $res = $this->userApi->deleteUser(self::$randomUsername1); - - $deleted_user = $this->userApi->getUserByName(self::$randomUsername1); - - $this->assertEquals($deleted_user, null); - - } - - public function testLoginUser() { - - $res = $this->userApi->loginUser("anyusername", "anypassword"); - - $this->assertEquals(substr($res, 0, 23), "logged in user session:"); - - } - - public function testLogoutUser() { - - $res = $this->userApi->logoutUser(); - - // We just want to make sure there are no errors in this test. - // To verify you are getting back a 200, you might want to add - // something like this to Swagger.php callAPI(): - // print "Response for call to $resourcePath : "; - // print_r($data); - - } - -} -?> \ No newline at end of file