You are here

public function ContextualLinkManagerTest::testPluginDefinitionAlter in Drupal 8

Tests the plugins alter hook.

File

core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php, line 373

Class

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

Namespace

Drupal\Tests\Core\Menu

Code

public function testPluginDefinitionAlter() {
  $definitions['test_plugin'] = [
    'id' => 'test_plugin',
    'class' => ContextualLinkDefault::class,
    'title' => 'Plugin',
    'weight' => 2,
    'group' => 'group1',
    'route_name' => 'test_route',
    'options' => [
      'key' => 'value',
    ],
  ];
  $this->pluginDiscovery
    ->expects($this
    ->once())
    ->method('getDefinitions')
    ->will($this
    ->returnValue($definitions));
  $this->moduleHandler
    ->expects($this
    ->once())
    ->method('alter')
    ->with('contextual_links_plugins', $definitions);
  $this->contextualLinkManager
    ->getDefinition('test_plugin');
}