public function CacheableMetadataTest::testAddCacheableDependency 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::testAddCacheableDependency()
@covers ::addCacheableDependency @dataProvider providerTestMerge
This only tests at a high level, because it reuses existing logic. Detailed tests exist for the existing logic:
See also
\Drupal\Tests\Core\Cache\CacheTest::testMergeTags()
\Drupal\Tests\Core\Cache\CacheTest::testMergeMaxAges()
\Drupal\Tests\Core\Cache\CacheContextsTest
File
- core/
tests/ Drupal/ Tests/ Core/ Cache/ CacheableMetadataTest.php, line 58 - Contains \Drupal\Tests\Core\Cache\CacheableMetadataTest.
Class
- CacheableMetadataTest
- @coversDefaultClass \Drupal\Core\Cache\CacheableMetadata @group Cache
Namespace
Drupal\Tests\Core\CacheCode
public function testAddCacheableDependency(CacheableMetadata $a, CacheableMetadata $b, CacheableMetadata $expected) {
$cache_contexts_manager = $this
->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')
->disableOriginalConstructor()
->getMock();
$cache_contexts_manager
->method('assertValidTokens')
->willReturn(TRUE);
$container = new ContainerBuilder();
$container
->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
$this
->assertEquals($expected, $a
->addCacheableDependency($b));
}