public function DateFormatAccessControlHandlerTest::testAccessProvider in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php \Drupal\Tests\system\Kernel\DateFormatAccessControlHandlerTest::testAccessProvider()
- 9 core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php \Drupal\Tests\system\Kernel\DateFormatAccessControlHandlerTest::testAccessProvider()
File
- core/
modules/ system/ tests/ src/ Kernel/ DateFormatAccessControlHandlerTest.php, line 83
Class
- DateFormatAccessControlHandlerTest
- @coversDefaultClass \Drupal\system\DateFormatAccessControlHandler @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 site configuration' permission is required."),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer site configuration' permission is required.")
->addCacheTags([
'rendered',
]),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer site configuration' permission is required.")
->addCacheTags([
'rendered',
]),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer site configuration' permission is required."),
],
'permissionless + locked' => [
'permissionless',
'locked',
AccessResult::allowed(),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer site configuration' permission is required."),
AccessResult::forbidden()
->addCacheTags([
'rendered',
])
->setReason("The DateFormat config entity is locked."),
AccessResult::forbidden()
->addCacheTags([
'rendered',
])
->setReason("The DateFormat config entity is locked."),
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer site configuration' permission is required."),
],
'admin + unlocked' => [
'admin',
'unlocked',
AccessResult::allowed(),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
])
->addCacheTags([
'rendered',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
])
->addCacheTags([
'rendered',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'admin + locked' => [
'admin',
'locked',
AccessResult::allowed(),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::forbidden()
->addCacheTags([
'rendered',
])
->setReason("The DateFormat config entity is locked."),
AccessResult::forbidden()
->addCacheTags([
'rendered',
])
->setReason("The DateFormat 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',
])
->addCacheTags([
'rendered',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
])
->addCacheTags([
'rendered',
]),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'user1 + locked' => [
'user1',
'locked',
AccessResult::allowed(),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
AccessResult::forbidden()
->addCacheTags([
'rendered',
])
->setReason("The DateFormat config entity is locked."),
AccessResult::forbidden()
->addCacheTags([
'rendered',
])
->setReason("The DateFormat config entity is locked."),
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
];
}