You are here

protected function ResourceTestBase::revokePermissionsFromTestedRole in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::revokePermissionsFromTestedRole()

Revokes permissions from the authenticated role.

Parameters

string[] $permissions: Permissions to revoke.

2 calls to ResourceTestBase::revokePermissionsFromTestedRole()
CommentTest::testCollectionFilterAccess in core/modules/jsonapi/tests/src/Functional/CommentTest.php
NodeTest::testCollectionFilterAccess in core/modules/jsonapi/tests/src/Functional/NodeTest.php

File

core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php, line 665

Class

ResourceTestBase
Subclass this for every JSON:API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function revokePermissionsFromTestedRole(array $permissions) {
  $role = Role::load(RoleInterface::AUTHENTICATED_ID);
  foreach ($permissions as $permission) {
    $role
      ->revokePermission($permission);
  }
  $role
    ->trustData()
    ->save();
}