Akihito Nakano 34abedeb8a
[PHP] Bump minimum required version to PHP7.1 (#1491)
* 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
2018-11-26 08:59:22 +07:00

38 lines
950 B
PHP

<?php
namespace OpenAPI\Client;
use OpenAPI\Client\Api\FakeApi;
use PHPUnit\Framework\TestCase;
require_once __DIR__ . '/FakeHttpClient.php';
class RequestTest extends 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&param2=value2', $requestContent);
}
}