[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:
baartosz
2017-06-04 18:36:40 +02:00
committed by wing328
parent 08a11c1d75
commit d7202a7c76
14 changed files with 681 additions and 337 deletions

View File

@@ -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);
}
}