All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
php-symfony.testing.ControllerTest.mustache Maven / Gradle / Ivy
partial_header}}
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the endpoint.
*/
namespace {{controllerTestsPackage}};
use {{controllerPackage}}\Controller;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
/**
* ControllerTest Class Doc Comment
*
* @category Class
* @package {{controllerTestsPackage}}
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \{{controllerPackage}}\Controller
*/
class ControllerTest extends TestCase
{
/**
* Tests isContentTypeAllowed static method.
*
* @covers ::isContentTypeAllowed
* @dataProvider dataProviderIsContentTypeAllowed
*/
public function testIsContentTypeAllowed(?string $contentType, array $consumes, bool $expectedReturn): void
{
$request = new Request();
$request->headers->set('CONTENT_TYPE', $contentType);// last one argument overrides header
$this->assertSame(
$expectedReturn,
Controller::isContentTypeAllowed($request, $consumes),
sprintf(
'Failed assertion that "Content-Type: %s" %s by [%s] consumes array.',
$contentType,
($expectedReturn) ? 'is allowed' : 'is forbidden',
implode(', ', $consumes)
)
);
}
public function dataProviderIsContentTypeAllowed(): array
{
return [
'usual JSON content type' => [
'application/json',
['application/json'],
true,
],
'extended content type from PR #6078' => [
'application/json; charset=utf-8',
['application/json'],
true,
],
'more than one content types' => [
'application/json',
['application/xml', 'application/json; charset=utf-8'],
true,
],
'empty consumes array' => [
'application/json',
[],
true,
],
'empty consumes and content type' => [
null,
[],
true,
],
'consumes everything' => [
'application/json',
['*/*'],
true,
],
'fancy custom content type' => [
'foobar/foobaz',
['application/xml', 'foobar/foobaz; charset=utf-8'],
true,
],
'empty content type' => [
null,
['application/xml', 'application/json; charset=utf-8'],
false,
],
'content type out of consumes' => [
'text/html',
['application/xml', 'application/json; charset=utf-8'],
false,
],
];
}
}