You are here

protected function FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema()

Asserts revisionable and/or translatable characteristics of an entity type.

Parameters

bool $revisionable: Whether the entity type is revisionable or not.

bool $translatable: Whether the entity type is translatable or not.

bool $new_base_field: (optional) Whether a new base field was added as part of the update. Defaults to FALSE.

2 calls to FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema()
FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdates in core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
@covers ::updateFieldableEntityType @dataProvider providerTestFieldableEntityTypeUpdates
FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesErrorHandling in core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
Tests that a failed entity schema update preserves the existing data.

File

core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php, line 455

Class

FieldableEntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager's fieldable entity update functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function assertEntityTypeSchema($revisionable, $translatable, $new_base_field = FALSE) {

  // Check whether the 'new_base_field' field has been installed correctly.
  $field_storage_definition = $this->entityDefinitionUpdateManager
    ->getFieldStorageDefinition('new_base_field', $this->entityTypeId);
  if ($new_base_field) {
    $this
      ->assertNotNull($field_storage_definition);
  }
  else {
    $this
      ->assertNull($field_storage_definition);
  }
  if ($revisionable && $translatable) {
    $this
      ->assertRevisionableAndTranslatable();
  }
  elseif ($revisionable) {
    $this
      ->assertRevisionable();
  }
  elseif ($translatable) {
    $this
      ->assertTranslatable();
  }
  else {
    $this
      ->assertNonRevisionableAndNonTranslatable();
  }
  $this
    ->assertBundleFieldSchema($revisionable);
}