function PermissionCheckerTest::testHasPermissionMixed
Same name and namespace in other branches
- 10 core/tests/Drupal/Tests/Core/Session/PermissionCheckerTest.php \Drupal\Tests\Core\Session\PermissionCheckerTest::testHasPermissionMixed()
Tests the hasPermission method when mixed scopes and identifiers exist.
File
-
core/
tests/ Drupal/ Tests/ Core/ Session/ PermissionCheckerTest.php, line 79
Class
- PermissionCheckerTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Session%21PermissionChecker.php/class/PermissionChecker/11.x" title="Checks permissions for an account." class="local">\Drupal\Core\Session\PermissionChecker</a> @group Session
Namespace
Drupal\Tests\Core\SessionCode
public function testHasPermissionMixed() : void {
$calculated_permissions = new CalculatedPermissions((new RefinableCalculatedPermissions())->addItem(new CalculatedPermissionsItem([
'foo',
]))
->addItem(new CalculatedPermissionsItem([
'bar',
], identifier: 'other-identifier'))
->addItem(new CalculatedPermissionsItem([
'baz',
], FALSE, 'other-scope', 'other-identifier')));
$this->processor
->processAccessPolicies($this->account)
->willReturn($calculated_permissions);
$this->assertTrue($this->checker
->hasPermission('foo', $this->account));
$this->assertFalse($this->checker
->hasPermission('bar', $this->account));
$this->assertFalse($this->checker
->hasPermission('baz', $this->account));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.