You are here

public function BlockContentUpdateTest::testSimpleUpdates in Drupal 8

Tests the revision metadata fields and revision data table additions.

File

core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php, line 28

Class

BlockContentUpdateTest
Tests update functions for the Block Content module.

Namespace

Drupal\Tests\block_content\Functional\Update

Code

public function testSimpleUpdates() {
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $entity_type = $entity_definition_update_manager
    ->getEntityType('block_content');
  $this
    ->assertNull($entity_type
    ->getRevisionDataTable());
  $this
    ->runUpdates();
  $post_revision_created = $entity_definition_update_manager
    ->getFieldStorageDefinition('revision_created', 'block_content');
  $post_revision_user = $entity_definition_update_manager
    ->getFieldStorageDefinition('revision_user', 'block_content');
  $this
    ->assertInstanceOf(BaseFieldDefinition::class, $post_revision_created);
  $this
    ->assertInstanceOf(BaseFieldDefinition::class, $post_revision_user);
  $this
    ->assertEqual('created', $post_revision_created
    ->getType(), "Field is type created");
  $this
    ->assertEqual('entity_reference', $post_revision_user
    ->getType(), "Field is type entity_reference");
  $entity_type = $entity_definition_update_manager
    ->getEntityType('block_content');
  $this
    ->assertEqual('block_content_field_revision', $entity_type
    ->getRevisionDataTable());
}