function ContextualLinkManagerTest::testPluginDefinitionAlter

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testPluginDefinitionAlter()
  2. 8.9.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testPluginDefinitionAlter()
  3. 10 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 310

Class

ContextualLinkManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Menu%21ContextualLinkManager.php/class/ContextualLinkManager/11.x" title="Defines a contextual link plugin manager to deal with contextual links." class="local">\Drupal\Core\Menu\ContextualLinkManager</a> @group Menu

Namespace

Drupal\Tests\Core\Menu

Code

public function testPluginDefinitionAlter() : void {
    $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
        ->alter('contextual_links_plugins', $definitions)
        ->shouldBeCalledOnce();
    $this->contextualLinkManager
        ->getDefinition('test_plugin');
}

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