function ContextualLinkManagerTest::testPluginDefinitionAlter

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testPluginDefinitionAlter()
  2. 10 core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testPluginDefinitionAlter()
  3. 11.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testPluginDefinitionAlter()

Tests the plugins alter hook.

File

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

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')
        ->willReturn($definitions);
    $this->moduleHandler
        ->expects($this->once())
        ->method('alter')
        ->with('contextual_links_plugins', $definitions);
    $this->contextualLinkManager
        ->getDefinition('test_plugin');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.