function FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema()

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

@internal

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.

1 call to FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema()
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 307

Class

FieldableEntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager's fieldable entity update functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function assertEntityTypeSchema(bool $revisionable, bool $translatable, bool $new_base_field = FALSE) : void {
    // 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.