3 namespace Drupal\Tests\user\Kernel;
5 use Drupal\KernelTests\KernelTestBase;
6 use Drupal\user\Entity\Role;
11 class UserRoleEntityTest extends KernelTestBase {
13 public static $modules = ['system', 'user'];
15 public function testOrderOfPermissions() {
16 $role = Role::create(['id' => 'test_role']);
17 $role->grantPermission('b')
18 ->grantPermission('a')
19 ->grantPermission('c')
21 $this->assertEquals($role->getPermissions(), ['a', 'b', 'c']);
23 $role->revokePermission('b')->save();
24 $this->assertEquals($role->getPermissions(), ['a', 'c']);
26 $role->grantPermission('b')->save();
27 $this->assertEquals($role->getPermissions(), ['a', 'b', 'c']);