function EntityAccessTest::testEntityAccessDefaultController

Ensures that the default controller is used as a fallback.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php, line 91
Contains Drupal\system\Tests\Entity\EntityAccessTest.

Class

EntityAccessTest
Tests the entity access controller.

Namespace

Drupal\system\Tests\Entity

Code

function testEntityAccessDefaultController() {

  // The implementation requires that the global user id can be loaded.
  global $user;
  $user = $this
    ->createUser(array(
    'uid' => 2,
  ));

  // Check that the default access controller is used for entities that don't
  // have a specific access controller defined.
  $controller = $this->container
    ->get('plugin.manager.entity')
    ->getAccessController('entity_test_default_access');
  $this
    ->assertTrue($controller instanceof EntityAccessController, 'The default entity controller is used for the entity_test_default_access entity type.');
  $entity = entity_create('entity_test_default_access', array());
  $this
    ->assertEntityAccess(array(
    'create' => FALSE,
    'update' => FALSE,
    'delete' => FALSE,
    'view' => FALSE,
  ), $entity);
}