You are here

public function ContextualLinkManagerTest::testGetContextualLinkPluginsByGroupWithCache in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 177
Contains \Drupal\Tests\Core\Menu\ContextualLinkManagerTest.

Class

ContextualLinkManagerTest
@coversDefaultClass \Drupal\Core\Menu\ContextualLinkManager @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

public function testGetContextualLinkPluginsByGroupWithCache() {
  $definitions = array(
    'test_plugin1' => array(
      'id' => 'test_plugin1',
      'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
      'group' => 'group1',
      'route_name' => 'test_route',
    ),
    'test_plugin2' => array(
      '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) array(
    '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);
}