function ContextualLinkManagerTest::testPluginDefinitionAlter

Same name 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. 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 310

Class

ContextualLinkManagerTest
@coversDefaultClass \Drupal\Core\Menu\ContextualLinkManager @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.