function CacheableMetadataTest::testAddCacheTags
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testAddCacheTags()
- 10 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 87
Class
- CacheableMetadataTest
- @coversDefaultClass \Drupal\Core\Cache\CacheableMetadata @group Cache
Namespace
Drupal\Tests\Core\CacheCode
public function testAddCacheTags() {
$metadata = new CacheableMetadata();
$add_expected = [
[
[],
[],
],
[
[
'foo:bar',
],
[
'foo:bar',
],
],
[
[
'foo:baz',
],
[
'foo:bar',
'foo:baz',
],
],
[
[
'axx:first',
'foo:baz',
],
[
'axx:first',
'foo:bar',
'foo:baz',
],
],
[
[],
[
'axx:first',
'foo:bar',
'foo:baz',
],
],
[
[
'axx:first',
],
[
'axx:first',
'foo:bar',
'foo:baz',
],
],
];
foreach ($add_expected as $data) {
list($add, $expected) = $data;
$metadata->addCacheTags($add);
$this->assertEquals($expected, $metadata->getCacheTags());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.