function EntityAccessControlHandlerTest::testEntityAccessDefaultController in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php \Drupal\system\Tests\Entity\EntityAccessControlHandlerTest::testEntityAccessDefaultController()
Ensures that the default handler is used as a fallback.
File
- core/
modules/ system/ src/ Tests/ Entity/ EntityAccessControlHandlerTest.php, line 100 - Contains \Drupal\system\Tests\Entity\EntityAccessControlHandlerTest.
Class
- EntityAccessControlHandlerTest
- Tests the entity access control handler.
Namespace
Drupal\system\Tests\EntityCode
function testEntityAccessDefaultController() {
// The implementation requires that the global user id can be loaded.
\Drupal::currentUser()
->setAccount($this
->createUser(array(
'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.manager')
->getAccessControlHandler('entity_test_default_access');
$this
->assertTrue($handler instanceof EntityAccessControlHandler, 'The default entity handler is used for the entity_test_default_access entity type.');
$entity = entity_create('entity_test_default_access');
$this
->assertEntityAccess(array(
'create' => FALSE,
'update' => FALSE,
'delete' => FALSE,
'view' => FALSE,
), $entity);
}