function UserRoleEntityTest::testOrderOfPermissions
Same name in other branches
- 9 core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testOrderOfPermissions()
- 8.9.x core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testOrderOfPermissions()
- 10 core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testOrderOfPermissions()
File
-
core/
modules/ user/ tests/ src/ Kernel/ UserRoleEntityTest.php, line 21
Class
- UserRoleEntityTest
- @group user @coversDefaultClass \Drupal\user\Entity\Role
Namespace
Drupal\Tests\user\KernelCode
public function testOrderOfPermissions() : void {
$role = Role::create([
'id' => 'test_role',
'label' => 'Test role',
]);
$role->grantPermission('b')
->grantPermission('a')
->grantPermission('c')
->save();
$this->assertEquals([
'a',
'b',
'c',
], $role->getPermissions());
$role->revokePermission('b')
->save();
$this->assertEquals([
'a',
'c',
], $role->getPermissions());
$role->grantPermission('b')
->save();
$this->assertEquals([
'a',
'b',
'c',
], $role->getPermissions());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.