You are here

public function RestJsonApiUnsupported::testApiJsonNotSupportedInRest in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/RestJsonApiUnsupported.php \Drupal\Tests\jsonapi\Functional\RestJsonApiUnsupported::testApiJsonNotSupportedInRest()

Deploying a REST resource using api_json format results in 406 responses.

File

tests/src/Functional/RestJsonApiUnsupported.php, line 84

Class

RestJsonApiUnsupported
Ensures that the 'api_json' format is not supported by the REST module.

Namespace

Drupal\Tests\jsonapi\Functional

Code

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(406, FALSE, $response);
}