public function ContextualLinkManagerTest::testGetContextualLinkPluginsByGroupWithCache in Drupal 8
Tests the getContextualLinkPluginsByGroup method with a prefilled cache.
File
- core/
tests/ Drupal/ Tests/ Core/ Menu/ ContextualLinkManagerTest.php, line 175
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')
->will($this
->returnValue((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);
}