You are here

protected function JsonApiDocumentTopLevelNormalizerTest::decorateRequest in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest::decorateRequest()

Decorates a request with sparse fieldsets and includes.

1 call to JsonApiDocumentTopLevelNormalizerTest::decorateRequest()
JsonApiDocumentTopLevelNormalizerTest::testCacheableMetadata in tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php
Ensure that cacheability metadata is properly added.

File

tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php, line 720

Class

JsonApiDocumentTopLevelNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi @group legacy

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

protected function decorateRequest(Request $request, array $fields = NULL, array $includes = NULL) {
  $parameters = new ParameterBag();
  $parameters
    ->add($fields ? [
    'fields' => $fields,
  ] : []);
  $parameters
    ->add($includes ? [
    'include' => $includes,
  ] : []);
  $request->query = $parameters;
  return $request;
}