public function JsonApiDocumentTopLevelNormalizerTest::testCacheableMetadataProvider in JSON:API 8
Same name and namespace in other branches
- 8.2 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 702
Class
- JsonApiDocumentTopLevelNormalizerTest
- @coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\NormalizerCode
public function testCacheableMetadataProvider() {
$cacheable_metadata = function ($metadata) {
return CacheableMetadata::createFromRenderArray([
'#cache' => $metadata,
]);
};
return [
[
floatval(\Drupal::VERSION) < 8.5 ? $cacheable_metadata([]) : $cacheable_metadata([
'contexts' => [
'languages:language_interface',
],
]),
[
'node--article' => 'body',
],
],
];
}