function ContextualLinkManagerTest::testGetContextualLinksArrayByGroupAccessCheck
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinksArrayByGroupAccessCheck()
- 8.9.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinksArrayByGroupAccessCheck()
- 11.x core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php \Drupal\Tests\Core\Menu\ContextualLinkManagerTest::testGetContextualLinksArrayByGroupAccessCheck()
Tests the access checking of the getContextualLinksArrayByGroup method.
See also
\Drupal\Core\Menu\ContextualLinkManager::getContextualLinksArrayByGroup()
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ ContextualLinkManagerTest.php, line 267
Class
- ContextualLinkManagerTest
- @coversDefaultClass \Drupal\Core\Menu\ContextualLinkManager @group Menu
Namespace
Drupal\Tests\Core\MenuCode
public function testGetContextualLinksArrayByGroupAccessCheck() : void {
$definitions = [
'test_plugin1' => [
'id' => 'test_plugin1',
'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
'title' => 'Plugin 1',
'weight' => 0,
'group' => 'group1',
'route_name' => 'test_route',
'options' => [],
],
'test_plugin2' => [
'id' => 'test_plugin2',
'class' => '\\Drupal\\Core\\Menu\\ContextualLinkDefault',
'title' => 'Plugin 2',
'weight' => 2,
'group' => 'group1',
'route_name' => 'test_route2',
'options' => [
'key' => 'value',
],
],
];
$this->pluginDiscovery
->expects($this->once())
->method('getDefinitions')
->willReturn($definitions);
$this->accessManager
->expects($this->any())
->method('checkNamedRoute')
->willReturnMap([
[
'test_route',
[
'key' => 'value',
],
$this->account,
FALSE,
TRUE,
],
[
'test_route2',
[
'key' => 'value',
],
$this->account,
FALSE,
FALSE,
],
]);
$result = $this->contextualLinkManager
->getContextualLinksArrayByGroup('group1', [
'key' => 'value',
]);
// Ensure that access checking was respected.
$this->assertTrue(isset($result['test_plugin1']));
$this->assertFalse(isset($result['test_plugin2']));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.