forked from loafle/openapi-generator-original
* Bump minimum required version to PHP7.1 ref: http://php.net/supported-versions.php * Bump phpunit * Update [api|model]_test.mustache * Update samples bin/openapi3/php-petstore.sh * Update namespace of PHPUnit ("tests" folder) * `setExpectedException` is deleted in PHPUnit 7.4 * Update namespace of "Assert" class * The attribute 'name' is required * Add anotation to exclude the test from risky testcheck * Update samples (samples/client/petstore/php) * Apply updates to "test" in openapi2 folder (samples/client/petstore/php)b3495ecbfe
15e00ae89d
2fc6917d13
0d016c00ed
* Install php7.1 * Switch to php7 * Update samples (security) bin/security/php-petstore.sh
43 lines
986 B
PHP
43 lines
986 B
PHP
<?php
|
|
|
|
namespace OpenAPI\Client;
|
|
|
|
use GuzzleHttp\Client;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ExceptionTest extends TestCase
|
|
{
|
|
/**
|
|
* @expectedException \OpenAPI\Client\ApiException
|
|
* @expectedExceptionCode 404
|
|
* @expectedExceptionMessage http://petstore.swagger.io/INVALID_URL/store/inventory
|
|
*/
|
|
public function testNotFound()
|
|
{
|
|
$config = new Configuration();
|
|
$config->setHost('http://petstore.swagger.io/INVALID_URL');
|
|
|
|
$api = new Api\StoreApi(
|
|
new Client(),
|
|
$config
|
|
);
|
|
$api->getInventory();
|
|
}
|
|
|
|
/**
|
|
* @expectedException \OpenAPI\Client\ApiException
|
|
* @expectedExceptionMessage Could not resolve host
|
|
*/
|
|
public function testWrongHost()
|
|
{
|
|
$config = new Configuration();
|
|
$config->setHost('http://wrong_host.zxc');
|
|
|
|
$api = new Api\StoreApi(
|
|
new Client(),
|
|
$config
|
|
);
|
|
$api->getInventory();
|
|
}
|
|
}
|