function BubbleableMetadataTest::testAddCacheableDependency
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php \Drupal\Tests\Core\Render\BubbleableMetadataTest::testAddCacheableDependency()
- 10 core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php \Drupal\Tests\Core\Render\BubbleableMetadataTest::testAddCacheableDependency()
- 11.x core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php \Drupal\Tests\Core\Render\BubbleableMetadataTest::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/ Render/ BubbleableMetadataTest.php, line 593
Class
- BubbleableMetadataTest
- @coversDefaultClass \Drupal\Core\Render\BubbleableMetadata @group Render
Namespace
Drupal\Tests\Core\RenderCode
public function testAddCacheableDependency(BubbleableMetadata $a, $b, BubbleableMetadata $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->assertEqualsCanonicalizing($expected, $a->addCacheableDependency($b));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.