public function RestJsonApiUnsupported::testApiJsonNotSupportedInRest in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/tests/src/Functional/RestJsonApiUnsupported.php \Drupal\Tests\jsonapi\Functional\RestJsonApiUnsupported::testApiJsonNotSupportedInRest()
Deploying a REST resource using api_json format results in 400 responses.
See also
\Drupal\jsonapi\EventSubscriber\JsonApiRequestValidator::validateQueryParams()
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ RestJsonApiUnsupported.php, line 90
Class
- RestJsonApiUnsupported
- Ensures that the 'api_json' format is not supported by the REST module.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testApiJsonNotSupportedInRest() {
$this
->assertSame([
'json',
'xml',
], $this->container
->getParameter('serializer.formats'));
$this
->provisionResource([
'api_json',
], []);
$this
->setUpAuthorization('GET');
$url = Node::load(1)
->toUrl()
->setOption('query', [
'_format' => 'api_json',
]);
$request_options = [];
$response = $this
->request('GET', $url, $request_options);
$this
->assertResourceErrorResponse(400, FALSE, $response, [
'4xx-response',
'config:user.role.anonymous',
'http_response',
'node:1',
], [
'url.query_args:_format',
'url.site',
'user.permissions',
], 'MISS', 'MISS');
}