function ContextualLinkManagerTest::testGetContextualLinkPluginsByGroup
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinkPluginsByGroup()
- 8.9.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinkPluginsByGroup()
- 10 core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinkPluginsByGroup()
Tests the getContextualLinkPluginsByGroup method.
See also
\Drupal\Core\Menu\ContextualLinkManager::getContextualLinkPluginsByGroup()
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ ContextualLinkManagerTest.php, line 103
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\MenuCode
public function testGetContextualLinkPluginsByGroup() : void {
$definitions = [
'test_plugin1' => [
'id' => 'test_plugin1',
'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route',
],
'test_plugin2' => [
'id' => 'test_plugin2',
'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
'group' => 'group1',
'route_name' => 'test_route2',
],
'test_plugin3' => [
'id' => 'test_plugin3',
'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
'group' => 'group2',
'route_name' => 'test_router3',
],
];
$this->pluginDiscovery
->expects($this->once())
->method('getDefinitions')
->willReturn($definitions);
// Test with a non existing group.
$result = $this->contextualLinkManager
->getContextualLinkPluginsByGroup('group_non_existing');
$this->assertEmpty($result);
$result = $this->contextualLinkManager
->getContextualLinkPluginsByGroup('group1');
$this->assertEquals([
'test_plugin1',
'test_plugin2',
], array_keys($result));
$result = $this->contextualLinkManager
->getContextualLinkPluginsByGroup('group2');
$this->assertEquals([
'test_plugin3',
], array_keys($result));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.