public function AccessManagerTest::testCheckConjunctions in Drupal 9
Same name and namespace in other branches
- 8 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 306 - Contains \Drupal\Tests\Core\Access\AccessManagerTest.
Class
- AccessManagerTest
- @coversDefaultClass \Drupal\Core\Access\AccessManager @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testCheckConjunctions($name, $condition_one, $condition_two, $expected_access) {
$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));
}