function CacheableMetadataTest::providerTestMerge
Provides test data for testMerge().
Return value
array
File
- 
              core/tests/ Drupal/ Tests/ Core/ Cache/ CacheableMetadataTest.php, line 69 
Class
- CacheableMetadataTest
- @coversDefaultClass \Drupal\Core\Cache\CacheableMetadata[[api-linebreak]] @group Cache
Namespace
Drupal\Tests\Core\CacheCode
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([
        '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.
