function ContextualLinkManagerTest::testGetContextualLinkPluginsByGroupWithCache
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[[api-linebreak]] @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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.