-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #602 from wing328/php_unit_test
Added unit testing for PHP Petstore client
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
## Requirements | ||
|
||
PHP 5.3.3 and later. | ||
|
||
## Composer | ||
|
||
You can install the bindings via [Composer](http://getcomposer.org/). Add this to your `composer.json`: | ||
|
||
{ | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/wing328/SwaggerPetstore-php.git" | ||
} | ||
], | ||
"require": { | ||
"SwaggerPetstore/SwaggerPetstore-php": "*@dev" | ||
} | ||
} | ||
|
||
Then install via: | ||
|
||
composer install | ||
|
||
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/00-intro.md#autoloading): | ||
|
||
require_once('vendor/autoload.php'); | ||
|
||
## Manual Installation | ||
|
||
If you do not wish to use Composer, you can download the latest release. Then, to use the bindings, include the `SwaggerPetstore.php` file. | ||
|
||
require_once('/path/to/SwaggerPetstore-php/SwaggerPetstore.php'); | ||
|
||
## Getting Started | ||
|
||
php test.php | ||
|
||
## Documentation | ||
|
||
TODO | ||
|
||
## Tests | ||
|
||
In order to run tests first install [PHPUnit](http://packagist.org/packages/phpunit/phpunit) via [Composer](http://getcomposer.org/): | ||
|
||
composer update | ||
|
||
To run the test suite: | ||
|
||
./vendor/bin/phpunit tests | ||
|
19 changes: 19 additions & 0 deletions
19
samples/client/petstore/php/SwaggerPetstore-php/tests/PetApiTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once('SwaggerPetstore.php'); | ||
|
||
class PetApiTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testGetPetById() | ||
{ | ||
// initialize the API client | ||
$api_client = new SwaggerPetstore\APIClient('http://petstore.swagger.io/v2'); | ||
$petId = 5; // ID of pet that needs to be fetched | ||
$pet_api = new SwaggerPetstore\PetAPI($api_client); | ||
// return Pet (model) | ||
$response = $pet_api->getPetById($petId); | ||
$this->assertSame($response->id, $petId); | ||
} | ||
} | ||
|
||
?> |