function ContextualLinkManagerTest::testGetContextualLinkPluginsByGroupWithCache
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinkPluginsByGroupWithCache()
- 10 core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinkPluginsByGroupWithCache()
- 11.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinkPluginsByGroupWithCache()
Tests the getContextualLinkPluginsByGroup method with a prefilled cache.
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ ContextualLinkManagerTest.php, line 143
Class
- ContextualLinkManagerTest
- @coversDefaultClass \Drupal\Core\Menu\ContextualLinkManager @group Menu
Namespace
Drupal\Tests\Core\MenuCode
public function testGetContextualLinkPluginsByGroupWithCache() {
$definitions = [
'test_plugin1' => [
'id' => 'test_plugin1',
'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route',
],
'test_plugin2' => [
'id' => 'test_plugin2',
'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route2',
],
];
$this->cacheBackend
->expects($this->once())
->method('get')
->with('contextual_links_plugins:en:group1')
->willReturn((object) [
'data' => $definitions,
]);
$result = $this->contextualLinkManager
->getContextualLinkPluginsByGroup('group1');
$this->assertEquals($definitions, $result);
// Ensure that the static cache works, so no second cache get is executed.
$result = $this->contextualLinkManager
->getContextualLinkPluginsByGroup('group1');
$this->assertEquals($definitions, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.