mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-10 08:31:22 +00:00
[php] 2.3 - fix form params json encoding (#5701)
* fixed tests expectations not compatible with phpunit 4 * added test and endpoint definition, updated template * regenerated sample * regenerated security sample
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Swagger\Client;
|
||||
|
||||
use Swagger\Client\Api\FakeApi;
|
||||
|
||||
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/json'], $contentType);
|
||||
|
||||
$requestContent = $request->getBody()->getContents();
|
||||
|
||||
$expected = json_encode(['param' => 'value', 'param2' => 'value2']);
|
||||
$this->assertEquals($expected, $requestContent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user