1<?php 2 3namespace Drupal\Tests\user\Kernel; 4 5use Drupal\KernelTests\KernelTestBase; 6use Drupal\user\Entity\Role; 7 8/** 9 * @group user 10 */ 11class UserRoleEntityTest extends KernelTestBase { 12 13 protected static $modules = ['system', 'user']; 14 15 public function testOrderOfPermissions() { 16 $role = Role::create(['id' => 'test_role']); 17 $role->grantPermission('b') 18 ->grantPermission('a') 19 ->grantPermission('c') 20 ->save(); 21 $this->assertEquals(['a', 'b', 'c'], $role->getPermissions()); 22 23 $role->revokePermission('b')->save(); 24 $this->assertEquals(['a', 'c'], $role->getPermissions()); 25 26 $role->grantPermission('b')->save(); 27 $this->assertEquals(['a', 'b', 'c'], $role->getPermissions()); 28 } 29 30} 31