public function RoleDelegationIntegrationTest::testRolesPage in User protect 8
Test that user protect rules are also enabled on /user/%user/roles.
File
- tests/
src/ Functional/ RoleDelegation/ RoleDelegationIntegrationTest.php, line 169
Class
- RoleDelegationIntegrationTest
- Functional tests for integration with role_delegation.
Namespace
Drupal\Tests\userprotect\Functional\RoleDelegationCode
public function testRolesPage() {
// Ensure that an anonymous user cannot access teh user protect settings
// page.
$this
->drupalGet('admin/config/people/userprotect/manage/protect_admin_role');
// Login as the delegated admin user. This user has permission to assign
// roles 1 and 2 to users.
$this
->drupalLogin($this->roleDelegatedAdminUser);
// Ensure that the delegated admin user can access its own roles edit page.
$this
->drupalGet(sprintf('/user/%s/roles', $this->roleDelegatedAdminUser
->id()));
$this
->assertSession()
->statusCodeEquals(200);
// Ensure that the delegated admin user cannot access the roles edit page of
// the admin user, since that user has a protected role.
$this
->drupalGet(sprintf('/user/%s/roles', $this->adminUser
->id()));
$this
->assertSession()
->statusCodeEquals(403);
// Login as roles admin user. This user has permission to assign all roles.
$this
->drupalLogin($this->regularRolesAdminUser);
// Ensure that the roles admin user cannot access any roles edit pages, as
// that requires specific Roles Delegation permissions.
$this
->drupalGet(sprintf('/user/%s/roles', $this->roleDelegatedAdminUser
->id()));
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalGet(sprintf('/user/%s/roles', $this->adminUser
->id()));
$this
->assertSession()
->statusCodeEquals(403);
// Login as an user with the admin role. This user has all privileges.
$this
->drupalLogin($this->adminUser);
// Ensure the admin user can access the roles edit page of all users.
$this
->drupalGet(sprintf('/user/%s/roles', $this->roleDelegatedAdminUser
->id()));
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet(sprintf('/user/%s/roles', $this->adminUser
->id()));
$this
->assertSession()
->statusCodeEquals(200);
}