public function EntityAccessCheckTest::testAuthenticatedDeniedOnCachedAccessUsingKernel in Permissions by Term 8.2
Same name and namespace in other branches
- 8 modules/permissions_by_entity/tests/src/Kernel/EntityAccessCheckTest.php \Drupal\Tests\permissions_by_entity\Kernel\EntityAccessCheckTest::testAuthenticatedDeniedOnCachedAccessUsingKernel()
Tests even listener based access control.
File
- modules/
permissions_by_entity/ tests/ src/ Kernel/ EntityAccessCheckTest.php, line 124
Class
- EntityAccessCheckTest
- Class EntityAccessCheckTest
Namespace
Drupal\Tests\permissions_by_entity\KernelCode
public function testAuthenticatedDeniedOnCachedAccessUsingKernel() {
$dispatcher = $this
->getPopulatedDispatcher();
// Execute first request for allowed user.
$this->container
->get('current_user')
->setAccount($this->terms['term_user_a']['user']);
$dispatcher
->dispatch(KernelEvents::REQUEST, $this
->getRequestResponseEvent());
$dispatcher
->dispatch(KernelEvents::RESPONSE, $this
->getCachableResponseEvent());
// Reset the cache to emulate a new request.
$this->container
->get('permissions_by_entity.checked_entity_cache')
->clear();
// Execute second request for disallowed user.
$this->container
->get('current_user')
->setAccount($this->terms['term_user_b']['user']);
$this
->setExpectedException(AccessDeniedHttpException::class);
$dispatcher
->dispatch(KernelEvents::REQUEST, $this
->getRequestResponseEvent());
}