function SuperUserPermissionsTest::testPermissionChange

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Session/SuperUserPermissionsTest.php \Drupal\KernelTests\Core\Session\SuperUserPermissionsTest::testPermissionChange()

Tests the super user access policy grants all permissions.

File

core/tests/Drupal/KernelTests/Core/Session/SuperUserPermissionsTest.php, line 41

Class

SuperUserPermissionsTest
Test case for getting all permissions as a super user.

Namespace

Drupal\KernelTests\Core\Session

Code

public function testPermissionChange() : void {
    $account = $this->createUser();
    $this->assertSame('1', $account->id());
    $this->assertTrue($account->hasPermission('administer modules'));
    $this->assertTrue($account->hasPermission('non-existent permission'));
    // Turn off the super user access policy and try again.
    $this->usesSuperUserAccessPolicy = FALSE;
    $this->bootKernel();
    $this->assertFalse($account->hasPermission('administer modules'));
    $this->assertFalse($account->hasPermission('non-existent permission'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.