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 83
Contains Drupal\system\Tests\Entity\EntityAccessTest.

Class

EntityAccessTest
Tests the entity access controller.

Namespace

Drupal\system\Tests\Entity

Code

function testEntityAccessDefaultController() {

  // Remove the access controller definition from the test entity.
  state()
    ->set('entity_test.default_access_controller', TRUE);

  // Check that the default access controller is used for entities that don't
  // have a specific access controller defined.
  $controller = entity_access_controller('entity_test');
  $this
    ->assertTrue($controller instanceof \Drupal\Core\Entity\EntityAccessController, 'The default entity controller is used for the entity_test entity type.');
  $entity = entity_create('entity_test', array());
  $this
    ->assertEntityAccess(array(
    'create' => FALSE,
    'update' => FALSE,
    'delete' => FALSE,
    'view' => FALSE,
  ), $entity);
}