function UserRoleEntityTest::testOrderOfPermissions

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testOrderOfPermissions()
  2. 10 core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testOrderOfPermissions()
  3. 11.x core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testOrderOfPermissions()

File

core/modules/user/tests/src/Kernel/UserRoleEntityTest.php, line 15

Class

UserRoleEntityTest
@group user

Namespace

Drupal\Tests\user\Kernel

Code

public function testOrderOfPermissions() {
    $role = Role::create([
        'id' => 'test_role',
    ]);
    $role->grantPermission('b')
        ->grantPermission('a')
        ->grantPermission('c')
        ->save();
    $this->assertEquals($role->getPermissions(), [
        'a',
        'b',
        'c',
    ]);
    $role->revokePermission('b')
        ->save();
    $this->assertEquals($role->getPermissions(), [
        'a',
        'c',
    ]);
    $role->grantPermission('b')
        ->save();
    $this->assertEquals($role->getPermissions(), [
        'a',
        'b',
        'c',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.