public function ContextualLinkManagerTest::testGetContextualLinkPluginsByGroup in Drupal 8
Tests the getContextualLinkPluginsByGroup method.
See also
\Drupal\Core\Menu\ContextualLinkManager::getContextualLinkPluginsByGroup()
File
- core/
tests/ Drupal/ Tests/ Core/ Menu/ ContextualLinkManagerTest.php, line 136
Class
- ContextualLinkManagerTest
- @coversDefaultClass \Drupal\Core\Menu\ContextualLinkManager @group Menu
Namespace
Drupal\Tests\Core\MenuCode
public function testGetContextualLinkPluginsByGroup() {
$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')
->will($this
->returnValue($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));
}