function AccessManagerTest::testCheckConjunctions
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckConjunctions()
- 8.9.x core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckConjunctions()
- 10 core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php \Drupal\Tests\Core\Access\AccessManagerTest::testCheckConjunctions()
Tests \Drupal\Core\Access\AccessManager::check() with conjunctions.
@dataProvider providerTestCheckConjunctions
File
-
core/
tests/ Drupal/ Tests/ Core/ Access/ AccessManagerTest.php, line 302
Class
- AccessManagerTest
- @coversDefaultClass \Drupal\Core\Access\AccessManager @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testCheckConjunctions($name, $condition_one, $condition_two, $expected_access) : void {
$this->setupAccessChecker();
$this->container
->register('test_access_defined', DefinedTestAccessCheck::class);
$this->checkProvider
->addCheckService('test_access_defined', 'access', [
'_test_access',
]);
$route_collection = new RouteCollection();
// Setup a test route for each access configuration.
$requirements = [
'_access' => $condition_one,
'_test_access' => $condition_two,
];
$route = new Route($name, [], $requirements);
$route_collection->add($name, $route);
$this->checkProvider
->setChecks($route_collection);
$this->setupAccessArgumentsResolverFactory();
$route_match = new RouteMatch($name, $route, [], []);
$this->assertEquals($expected_access->isAllowed(), $this->accessManager
->check($route_match, $this->account));
$this->assertEquals($expected_access, $this->accessManager
->check($route_match, $this->account, NULL, TRUE));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.