function SuperUserAccessPolicyTest::testAlterPermissions
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Session/SuperUserAccessPolicyTest.php \Drupal\Tests\Core\Session\SuperUserAccessPolicyTest::testAlterPermissions()
Tests the alterPermissions method.
@covers ::alterPermissions @dataProvider alterPermissionsProvider
Parameters
int $uid: The UID for the account the policy checks.
File
-
core/
tests/ Drupal/ Tests/ Core/ Session/ SuperUserAccessPolicyTest.php, line 104
Class
- SuperUserAccessPolicyTest
- @coversDefaultClass \Drupal\Core\Session\SuperUserAccessPolicy @group Session
Namespace
Drupal\Tests\Core\SessionCode
public function testAlterPermissions(int $uid) : void {
$account = $this->prophesize(AccountInterface::class);
$account->id()
->willReturn($uid);
$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.