public function MenuAccessControlHandlerTest::testAccessProvider in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Kernel/MenuAccessControlHandlerTest.php \Drupal\Tests\system\Kernel\MenuAccessControlHandlerTest::testAccessProvider()
- 10 core/modules/system/tests/src/Kernel/MenuAccessControlHandlerTest.php \Drupal\Tests\system\Kernel\MenuAccessControlHandlerTest::testAccessProvider()
File
- core/
modules/ system/ tests/ src/ Kernel/ MenuAccessControlHandlerTest.php, line 83
Class
- MenuAccessControlHandlerTest
- @coversDefaultClass \Drupal\system\MenuAccessControlHandler @group system
Namespace
Drupal\Tests\system\KernelCode
public function testAccessProvider() {
$c = new ContainerBuilder();
$cache_contexts_manager = $this
->prophesize(CacheContextsManager::class);
$cache_contexts_manager
->assertValidTokens()
->willReturn(TRUE);
$cache_contexts_manager
->reveal();
$c
->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($c);
return [
'permissionless + unlocked' => [
'permissionless',
'unlocked',
AccessResult::allowed(),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer menu' permission is required."),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer menu' permission is required."),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer menu' permission is required.")
->addCacheTags([
'config:system.menu.llama',
]),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer menu' permission is required."),
],
'permissionless + locked' => [
'permissionless',
'locked',
AccessResult::allowed(),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer menu' permission is required."),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer menu' permission is required."),
AccessResult::forbidden()
->addCacheTags([
'config:system.menu.llama',
])
->setReason("The Menu config entity is locked."),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer menu' permission is required."),
],
'admin + unlocked' => [
'admin',
'unlocked',
AccessResult::allowed(),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
])
->addCacheTags([
'config:system.menu.llama',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'admin + locked' => [
'admin',
'locked',
AccessResult::allowed(),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::forbidden()
->addCacheTags([
'config:system.menu.llama',
])
->setReason("The Menu config entity is locked."),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'user1 + unlocked' => [
'user1',
'unlocked',
AccessResult::allowed(),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
])
->addCacheTags([
'config:system.menu.llama',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'user1 + locked' => [
'user1',
'locked',
AccessResult::allowed(),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::forbidden()
->addCacheTags([
'config:system.menu.llama',
])
->setReason("The Menu config entity is locked."),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
];
}