public function CacheableMetadataTest::testAddCacheTags in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 93 - Contains \Drupal\Tests\Core\Cache\CacheableMetadataTest.
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());
}
}