public function PermissionAccessCheckTest::testAccess in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php \Drupal\Tests\user\Unit\PermissionAccessCheckTest::testAccess()
Tests the access check method.
@dataProvider providerTestAccess @covers ::access
File
- core/
modules/ user/ tests/ src/ Unit/ PermissionAccessCheckTest.php, line 76 - Contains \Drupal\Tests\user\Unit\PermissionAccessCheckTest.
Class
- PermissionAccessCheckTest
- @coversDefaultClass \Drupal\user\Access\PermissionAccessCheck @group Routing @group AccessF
Namespace
Drupal\Tests\user\UnitCode
public function testAccess($requirements, $access, array $contexts = []) {
$access_result = AccessResult::allowedIf($access)
->addCacheContexts($contexts);
$user = $this
->getMock('Drupal\\Core\\Session\\AccountInterface');
$user
->expects($this
->any())
->method('hasPermission')
->will($this
->returnValueMap([
[
'allowed',
TRUE,
],
[
'denied',
FALSE,
],
[
'other',
FALSE,
],
]));
$route = new Route('', [], $requirements);
$this
->assertEquals($access_result, $this->accessCheck
->access($route, $user));
}