protected function PBTKernelTestBase::createAdminUser in Permissions by Term 8.2
1 call to PBTKernelTestBase::createAdminUser()
- PBTKernelTestBase::setUp in tests/
src/ Kernel/ PBTKernelTestBase.php
File
- tests/
src/ Kernel/ PBTKernelTestBase.php, line 144
Class
- PBTKernelTestBase
- Class PBTKernelTestBase
Namespace
Drupal\Tests\permissions_by_term\KernelCode
protected function createAdminUser() {
if (($role = Role::load('administrator')) === null) {
$role = [
'id' => 'administrator',
'label' => 'administrator',
'permissions' => [
'access comments',
'administer comments',
'post comments',
'post comments without approval',
'access content',
'administer content types',
'administer nodes',
'bypass node access',
],
];
try {
Role::create($role)
->save();
} catch (EntityStorageException $exception) {
exit($exception
->getMessage());
}
}
$adminUser = User::create([
'uid' => 1,
'name' => 'admin',
'roles' => [
'administrator',
],
]);
$adminUser
->save();
}