function UserRolesAccessPolicyTest::testAlterPermissions

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php \Drupal\Tests\Core\Session\UserRolesAccessPolicyTest::testAlterPermissions()

Tests the alterPermissions method.

@covers ::alterPermissions

File

core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php, line 166

Class

UserRolesAccessPolicyTest
@coversDefaultClass \Drupal\Core\Session\UserRolesAccessPolicy[[api-linebreak]] @group Session

Namespace

Drupal\Tests\Core\Session

Code

public function testAlterPermissions() : void {
  $account = $this->prophesize(AccountInterface::class);
  $calculated_permissions = new RefinableCalculatedPermissions();
  $calculated_permissions->addItem(new CalculatedPermissionsItem([
    'foo',
  ]));
  $calculated_permissions->addCacheTags([
    'bar',
  ]);
  $calculated_permissions->addCacheContexts([
    'baz',
  ]);
  $this->accessPolicy
    ->alterPermissions($account->reveal(), AccessPolicyInterface::SCOPE_DRUPAL, $calculated_permissions);
  $this->assertSame([
    'foo',
  ], $calculated_permissions->getItem()
    ->getPermissions());
  $this->assertSame([
    'bar',
  ], $calculated_permissions->getCacheTags());
  $this->assertSame([
    'baz',
  ], $calculated_permissions->getCacheContexts());
}

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