function UserRoleEntityTest::testPermissionRevokeAndConfigSync

Same name in other branches
  1. 9 core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testPermissionRevokeAndConfigSync()
  2. 10 core/modules/user/tests/src/Kernel/UserRoleEntityTest.php \Drupal\Tests\user\Kernel\UserRoleEntityTest::testPermissionRevokeAndConfigSync()

File

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

Class

UserRoleEntityTest
@group user @coversDefaultClass \Drupal\user\Entity\Role

Namespace

Drupal\Tests\user\Kernel

Code

public function testPermissionRevokeAndConfigSync() : void {
    $role = Role::create([
        'id' => 'test_role',
        'label' => 'Test role',
    ]);
    $role->setSyncing(TRUE);
    $role->grantPermission('a')
        ->grantPermission('b')
        ->grantPermission('c')
        ->save();
    $this->assertSame([
        'a',
        'b',
        'c',
    ], $role->getPermissions());
    $role->revokePermission('b')
        ->save();
    $this->assertSame([
        'a',
        'c',
    ], $role->getPermissions());
}

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