forked from loafle/openapi-generator-original
* Update php client with petstore OpenAPI v2 spec bin/php-petstore.sh * Change order of arguments according to the changes that auto-generated codes * Fix 'FakeHttpClient not found' error It has occured when run the test case separately like below. "vendor/bin/phpunit tests/RequestTest.php" * Update assertion according to a change on spec * Update assertion
37 lines
937 B
PHP
37 lines
937 B
PHP
<?php
|
|
|
|
namespace Swagger\Client;
|
|
|
|
use Swagger\Client\Api\FakeApi;
|
|
|
|
require_once __DIR__ . '/FakeHttpClient.php';
|
|
|
|
class RequestTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
|
|
/** @var FakeApi */
|
|
private $api;
|
|
/** @var FakeHttpClient */
|
|
private $fakeClient;
|
|
|
|
public function setUp()
|
|
{
|
|
$this->fakeClient = new FakeHttpClient();
|
|
$this->api = new Api\FakeApi($this->fakeClient);
|
|
}
|
|
|
|
public function testFormDataEncodingToJson()
|
|
{
|
|
$this->api->testJsonFormData('value', 'value2');
|
|
|
|
$request = $this->fakeClient->getLastRequest();
|
|
$contentType = $request->getHeader('Content-Type');
|
|
$this->assertEquals(['application/x-www-form-urlencoded'], $contentType);
|
|
|
|
$requestContent = $request->getBody()->getContents();
|
|
|
|
// JSON serialization of form data is not supported
|
|
$this->assertEquals('param=value¶m2=value2', $requestContent);
|
|
}
|
|
}
|