function CacheableMetadataTest::providerTestMerge

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::providerTestMerge()
  2. 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::providerTestMerge()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::providerTestMerge()

Provides test data for testMerge().

Return value

array

File

core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php, line 71

Class

CacheableMetadataTest
@coversDefaultClass \Drupal\Core\Cache\CacheableMetadata @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public static function providerTestMerge() {
    return [
        // All empty.
[
            new CacheableMetadata(),
            new CacheableMetadata(),
            new CacheableMetadata(),
        ],
        // Cache contexts.
[
            (new CacheableMetadata())->setCacheContexts([
                'foo',
            ]),
            (new CacheableMetadata())->setCacheContexts([
                'bar',
            ]),
            (new CacheableMetadata())->setCacheContexts([
                'bar',
                'foo',
            ]),
        ],
        // Cache tags.
[
            (new CacheableMetadata())->setCacheTags([
                'foo',
            ]),
            (new CacheableMetadata())->setCacheTags([
                'bar',
            ]),
            (new CacheableMetadata())->setCacheTags([
                'foo',
                'bar',
            ]),
        ],
        // Cache max-ages.
[
            (new CacheableMetadata())->setCacheMaxAge(60),
            (new CacheableMetadata())->setCacheMaxAge(Cache::PERMANENT),
            (new CacheableMetadata())->setCacheMaxAge(60),
        ],
    ];
}

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