function CacheableMetadataTest::testAddCacheTags
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testAddCacheTags()
- 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testAddCacheTags()
- 11.x core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testAddCacheTags()
This delegates to Cache::mergeTags(), so just a basic test.
@covers ::addCacheTags
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ CacheableMetadataTest.php, line 89
Class
- CacheableMetadataTest
- @coversDefaultClass \Drupal\Core\Cache\CacheableMetadata @group Cache
Namespace
Drupal\Tests\Core\CacheCode
public function testAddCacheTags() : void {
$metadata = new CacheableMetadata();
$add_expected = [
[
[],
[],
],
[
[
'foo:bar',
],
[
'foo:bar',
],
],
[
[
'foo:baz',
],
[
'foo:bar',
'foo:baz',
],
],
[
[
'axx:first',
'foo:baz',
],
[
'foo:bar',
'foo:baz',
'axx:first',
],
],
[
[],
[
'foo:bar',
'foo:baz',
'axx:first',
],
],
[
[
'axx:first',
],
[
'foo:bar',
'foo:baz',
'axx:first',
],
],
];
foreach ($add_expected as $row => $data) {
[
$add,
$expected,
] = $data;
$metadata->addCacheTags($add);
$this->assertEquals($expected, $metadata->getCacheTags(), sprintf("Dataset in %d row failed on validation.", $row + 1));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.