You are here

public function EntityDefinitionUpdateTest::testNewEntityType in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityDefinitionUpdateTest.php \Drupal\system\Tests\Entity\EntityDefinitionUpdateTest::testNewEntityType()

Tests that new entity type definitions are correctly handled.

File

core/modules/system/src/Tests/Entity/EntityDefinitionUpdateTest.php, line 64
Contains \Drupal\system\Tests\Entity\EntityDefinitionUpdateTest.

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\system\Tests\Entity

Code

public function testNewEntityType() {
  $entity_type_id = 'entity_test_new';
  $schema = $this->database
    ->schema();

  // Check that the "entity_test_new" is not defined.
  $entity_types = $this->entityManager
    ->getDefinitions();
  $this
    ->assertFalse(isset($entity_types[$entity_type_id]), 'The "entity_test_new" entity type does not exist.');
  $this
    ->assertFalse($schema
    ->tableExists($entity_type_id), 'Schema for the "entity_test_new" entity type does not exist.');

  // Check that the "entity_test_new" is now defined and the related schema
  // has been created.
  $this
    ->enableNewEntityType();
  $entity_types = $this->entityManager
    ->getDefinitions();
  $this
    ->assertTrue(isset($entity_types[$entity_type_id]), 'The "entity_test_new" entity type exists.');
  $this
    ->assertTrue($schema
    ->tableExists($entity_type_id), 'Schema for the "entity_test_new" entity type has been created.');
}