class SuperUserPermissionsTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Session/SuperUserPermissionsTest.php \Drupal\KernelTests\Core\Session\SuperUserPermissionsTest
Test case for getting all permissions as a super user.
@covers \Drupal\Core\DependencyInjection\Compiler\SuperUserAccessPolicyPass
@group Session
Hierarchy
- class \Drupal\KernelTests\Core\Session\SuperUserPermissionsTest
Expanded class hierarchy of SuperUserPermissionsTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Session/ SuperUserPermissionsTest.php, line 16
Namespace
Drupal\KernelTests\Core\SessionView source
class SuperUserPermissionsTest extends KernelTestBase {
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'user',
];
/**
* {@inheritdoc}
*/
protected bool $usesSuperUserAccessPolicy = TRUE;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('user');
}
/**
* Tests the super user access policy grants all permissions.
*/
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'));
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ExtensionListTestTrait::getModulePath | protected | function | Gets the path for the specified module. |
ExtensionListTestTrait::getThemePath | protected | function | Gets the path for the specified theme. |
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. |
SuperUserPermissionsTest::$modules | protected static | property | Modules to install. |
SuperUserPermissionsTest::$usesSuperUserAccessPolicy | protected | property | Set to TRUE to make user 1 a super user. |
SuperUserPermissionsTest::setUp | protected | function | |
SuperUserPermissionsTest::testPermissionChange | public | function | Tests the super user access policy grants all permissions. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.