You are here

public function EntityDefinitionUpdateTest::testEntityTypeSchemaUpdateAndRevisionableBaseFieldCreateWithoutData 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::testEntityTypeSchemaUpdateAndRevisionableBaseFieldCreateWithoutData()

Tests updating entity schema and creating a revisionable base field.

This tests updating entity schema and creating a revisionable base field at the same time when there are no existing entities.

File

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

Class

EntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager functionality.

Namespace

Drupal\system\Tests\Entity

Code

public function testEntityTypeSchemaUpdateAndRevisionableBaseFieldCreateWithoutData() {
  $this
    ->updateEntityTypeToRevisionable();
  $this
    ->addRevisionableBaseField();
  $message = 'Successfully updated entity schema and created revisionable base field at the same time.';

  // Entity type updates create base fields as well, thus make sure doing both
  // at the same time does not lead to errors due to the base field being
  // created twice.
  try {
    $this->entityDefinitionUpdateManager
      ->applyUpdates();
    $this
      ->pass($message);
  } catch (\Exception $e) {
    $this
      ->fail($message);
    throw $e;
  }
}