forked from loafle/openapi-generator-original
* Set PHP 7.2 as minimum version * Update PHPUnit to 8 || 9 * Set Bionic environment in Travis config * PHPUnit 8 requires void return in static methods * PHPUnit 8 requires void return in static methods * Fix curl exception message test When I run "curl http://wrong_host.zxc" output is: curl: (6) Could not resolve host: wrong_host.zxc Maybe this message is different across versions. Tested curl version: curl 7.54.0 (x86_64-apple-darwin18.0) libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1 * Update assertions of deprecated assertInternalType * Migrate to expectException method of PHPUnit 8 * Fix PHPCS Fixer errors * Replace deprecated 'assertRegExp' assertion * Exclude PHPUnit and php-cs-fixer cache * Refresh samples * Set root Travis CI environment to PHP 7.2.5 * Change to 7.3 as 7.2.27 is highest preinstalled * Fix testWrongHost test
67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace OpenAPI\Client;
|
|
|
|
use OpenAPI\Client\Api\FakeApi;
|
|
use OpenAPI\Client\Api\UserApi;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
require_once __DIR__ . '/FakeHttpClient.php';
|
|
|
|
class ParametersTest extends TestCase
|
|
{
|
|
/** @var FakeHttpClient */
|
|
private $fakeHttpClient;
|
|
/** @var FakeApi */
|
|
private $fakeApi;
|
|
/** @var UserApi */
|
|
private $userApi;
|
|
|
|
public function setUp(): void
|
|
{
|
|
$this->fakeHttpClient = new FakeHttpClient();
|
|
$this->fakeApi = new Api\FakeApi($this->fakeHttpClient);
|
|
$this->userApi = new Api\UserApi($this->fakeHttpClient);
|
|
}
|
|
|
|
public function testHeaderParam()
|
|
{
|
|
$this->fakeApi->testEnumParameters([], 'something');
|
|
|
|
$request = $this->fakeHttpClient->getLastRequest();
|
|
$headers = $request->getHeaders();
|
|
|
|
$this->assertArrayHasKey('enum_header_string', $headers);
|
|
$this->assertEquals(['something'], $headers['enum_header_string']);
|
|
}
|
|
|
|
public function testHeaderParamCollection()
|
|
{
|
|
$this->fakeApi->testEnumParameters(['string1', 'string2']);
|
|
|
|
$request = $this->fakeHttpClient->getLastRequest();
|
|
$headers = $request->getHeaders();
|
|
|
|
$this->assertArrayHasKey('enum_header_string_array', $headers);
|
|
$this->assertEquals(['string1,string2'], $headers['enum_header_string_array']);
|
|
}
|
|
|
|
public function testInlineAdditionalProperties()
|
|
{
|
|
$param = new \stdClass();
|
|
$param->foo = 'bar';
|
|
$this->fakeApi->testInlineAdditionalProperties($param);
|
|
|
|
$request = $this->fakeHttpClient->getLastRequest();
|
|
$this->assertSame('{"foo":"bar"}', $request->getBody()->getContents());
|
|
}
|
|
|
|
// missing example for collection path param in config
|
|
// public function testPathParamCollection()
|
|
// {
|
|
// $this->userApi->getUserByNameWithHttpInfo(['aa', 'bb']);
|
|
// $request = $this->fakeHttpClient->getLastRequest();
|
|
// $this->assertEquals('user/aa,bb', urldecode($request->getUri()->getPath()));
|
|
// }
|
|
}
|