public function AccessResultTest::testAllowedIfHasPermissions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 863 - Contains \Drupal\Tests\Core\Access\AccessResultTest.
Class
- AccessResultTest
- @coversDefaultClass \Drupal\Core\Access\AccessResult @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testAllowedIfHasPermissions($permissions, $conjunction, AccessResult $expected_access) {
$account = $this
->getMock('\\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);
}