You are here

public function CacheableMetadataTest::providerTestMerge in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 75
Contains \Drupal\Tests\Core\Cache\CacheableMetadataTest.

Class

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

Namespace

Drupal\Tests\Core\Cache

Code

public 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([
        'bar',
        'foo',
      ]),
    ],
    // Cache max-ages.
    [
      (new CacheableMetadata())
        ->setCacheMaxAge(60),
      (new CacheableMetadata())
        ->setCacheMaxAge(Cache::PERMANENT),
      (new CacheableMetadata())
        ->setCacheMaxAge(60),
    ],
  ];
}