public function DateFormatAccessControlHandlerTest::testAccess in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php \Drupal\Tests\system\Kernel\DateFormatAccessControlHandlerTest::testAccess()
- 10 core/modules/system/tests/src/Kernel/DateFormatAccessControlHandlerTest.php \Drupal\Tests\system\Kernel\DateFormatAccessControlHandlerTest::testAccess()
@covers ::checkAccess @covers ::checkCreateAccess @dataProvider testAccessProvider
File
- core/
modules/ system/ tests/ src/ Kernel/ DateFormatAccessControlHandlerTest.php, line 55
Class
- DateFormatAccessControlHandlerTest
- @coversDefaultClass \Drupal\system\DateFormatAccessControlHandler @group system
Namespace
Drupal\Tests\system\KernelCode
public function testAccess($which_user, $which_entity, $view_label_access_result, $view_access_result, $update_access_result, $delete_access_result, $create_access_result) {
// We must always create user 1, so that a "normal" user has a ID >1.
$root_user = $this
->drupalCreateUser();
if ($which_user === 'user1') {
$user = $root_user;
}
else {
$permissions = $which_user === 'admin' ? [
'administer site configuration',
] : [];
$user = $this
->drupalCreateUser($permissions);
}
$entity_values = $which_entity === 'unlocked' ? [
'locked' => FALSE,
] : [
'locked' => TRUE,
];
$entity_values['id'] = $this
->randomMachineName();
$entity = DateFormat::create($entity_values);
$entity
->save();
static::assertEquals($view_label_access_result, $this->accessControlHandler
->access($entity, 'view label', $user, TRUE));
static::assertEquals($view_access_result, $this->accessControlHandler
->access($entity, 'view', $user, TRUE));
static::assertEquals($update_access_result, $this->accessControlHandler
->access($entity, 'update', $user, TRUE));
static::assertEquals($delete_access_result, $this->accessControlHandler
->access($entity, 'delete', $user, TRUE));
static::assertEquals($create_access_result, $this->accessControlHandler
->createAccess(NULL, $user, [], TRUE));
}