function EntityAccessControlHandlerTest::testEntityAccessDefaultController
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::testEntityAccessDefaultController()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::testEntityAccessDefaultController()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::testEntityAccessDefaultController()
Ensures that the default handler is used as a fallback.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityAccessControlHandlerTest.php, line 176
Class
- EntityAccessControlHandlerTest
- Tests the entity access control handler.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testEntityAccessDefaultController() : void {
// The implementation requires that the global user id can be loaded.
\Drupal::currentUser()->setAccount($this->createUser([], NULL, FALSE, [
'uid' => 2,
]));
// Check that the default access control handler is used for entities that don't
// have a specific access control handler defined.
$handler = $this->container
->get('entity_type.manager')
->getAccessControlHandler('entity_test_default_access');
$this->assertInstanceOf(EntityAccessControlHandler::class, $handler);
$entity = EntityTestDefaultAccess::create();
$this->assertEntityAccess([
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
], $entity);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.