function JsonApiTopLevelResourceNormalizerTest::testCacheableMetadataProvider

Provides test cases for asserting cacheable metadata behavior.

File

core/modules/jsonapi/tests/src/Kernel/Normalizer/JsonApiTopLevelResourceNormalizerTest.php, line 827

Class

JsonApiTopLevelResourceNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.