public function RoleDelegationIntegrationTest::setUp in User protect 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ RoleDelegation/ RoleDelegationIntegrationTest.php, line 65
Class
- RoleDelegationIntegrationTest
- Functional tests for integration with role_delegation.
Namespace
Drupal\Tests\userprotect\Functional\RoleDelegationCode
public function setUp() {
parent::setUp();
$admin_role = $this
->createAdminRole();
$this->adminUser = $this
->createUser();
$this->adminUser
->addRole($admin_role);
$this->adminUser
->save();
$this->rid1 = $this
->drupalCreateRole([]);
$this->rid2 = $this
->drupalCreateRole([]);
$this->roleDelegatedAdminUser = $this
->drupalCreateUser([
'administer users',
sprintf('assign %s role', $this->rid1),
sprintf('assign %s role', $this->rid2),
]);
$this->regularRolesAdminUser = $this
->drupalCreateUser([
'administer users',
'administer permissions',
]);
// Create a protection rule to protect users with the admin role.
ProtectionRule::create([
'name' => 'protect_admin_role',
'label' => 'Protect admin role',
'protections' => [
'user_roles' => [
'status' => TRUE,
],
],
'protectedEntityTypeId' => 'user_role',
'protectedEntityId' => $admin_role,
])
->save();
}