function AccessResultTest::testAllowedIfHasPermissions
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAllowedIfHasPermissions()
- 8.9.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAllowedIfHasPermissions()
- 11.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAllowedIfHasPermissions()
Tests allowedIfHasPermissions().
@covers ::allowedIfHasPermissions
@dataProvider providerTestAllowedIfHasPermissions
Parameters
string[] $permissions: The permissions to check for.
string $conjunction: The conjunction to use when checking for permission. 'AND' or 'OR'.
\Drupal\Core\Access\AccessResult $expected_access: The expected access check result.
File
-
core/
tests/ Drupal/ Tests/ Core/ Access/ AccessResultTest.php, line 921
Class
- AccessResultTest
- @coversDefaultClass \Drupal\Core\Access\AccessResult @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testAllowedIfHasPermissions($permissions, $conjunction, AccessResult $expected_access) : void {
$account = $this->createMock('\\Drupal\\Core\\Session\\AccountInterface');
$account->expects($this->any())
->method('hasPermission')
->willReturnMap([
[
'allowed',
TRUE,
],
[
'denied',
FALSE,
],
]);
if ($permissions) {
$expected_access->cachePerPermissions();
}
$access_result = AccessResult::allowedIfHasPermissions($account, $permissions, $conjunction);
$this->assertEquals($expected_access, $access_result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.