Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / user / tests / src / Kernel / UserRoleEntityTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Kernel;
4
5 use Drupal\KernelTests\KernelTestBase;
6 use Drupal\user\Entity\Role;
7
8 /**
9  * @group user
10  */
11 class UserRoleEntityTest extends KernelTestBase {
12
13   public 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($role->getPermissions(), ['a', 'b', 'c']);
22
23     $role->revokePermission('b')->save();
24     $this->assertEquals($role->getPermissions(), ['a', 'c']);
25
26     $role->grantPermission('b')->save();
27     $this->assertEquals($role->getPermissions(), ['a', 'b', 'c']);
28   }
29
30 }