You are here

public function JsonApiDocumentTopLevelNormalizerTest::testCacheableMetadataProvider in JSON:API 8.2

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

Provides test cases for asserting cacheable metadata behavior.

File

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

Class

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

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

public function testCacheableMetadataProvider() {
  $cacheable_metadata = function ($metadata) {
    return CacheableMetadata::createFromRenderArray([
      '#cache' => $metadata,
    ]);
  };
  return [
    [
      $cacheable_metadata([
        'contexts' => [
          'languages:language_interface',
        ],
      ]),
      [
        'node--article' => 'body',
      ],
    ],
  ];
}