class FieldableEntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager's fieldable entity update functionality.
@coversDefaultClass \Drupal\Core\Entity\EntityDefinitionUpdateManager
      
    
@group Entity @group #slow
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest uses \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait extends \Drupal\KernelTests\Core\Entity\EntityKernelTestBase
 
 
 - class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait extends \Drupal\KernelTests\KernelTestBase
 
Expanded class hierarchy of FieldableEntityDefinitionUpdateTest
File
- 
              core/
tests/ Drupal/ KernelTests/ Core/ Entity/ FieldableEntityDefinitionUpdateTest.php, line 21  
Namespace
Drupal\KernelTests\Core\EntityView source
class FieldableEntityDefinitionUpdateTest extends EntityKernelTestBase {
  use EntityDefinitionTestTrait;
  
  /**
   * The entity definition update manager.
   *
   * @var \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface
   */
  protected $entityDefinitionUpdateManager;
  
  /**
   * The last installed schema repository service.
   *
   * @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface
   */
  protected $lastInstalledSchemaRepository;
  
  /**
   * The key-value collection for tracking installed storage schema.
   *
   * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface
   */
  protected $installedStorageSchema;
  
  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;
  
  /**
   * The entity field manager.
   *
   * @var \Drupal\Core\Entity\EntityFieldManagerInterface
   */
  protected $entityFieldManager;
  
  /**
   * The database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $database;
  
  /**
   * The ID of the entity type used in this test.
   *
   * @var string
   */
  protected $entityTypeId = 'entity_test_update';
  
  /**
   * An array of entities are created during the test.
   *
   * @var \Drupal\entity_test_update\Entity\EntityTestUpdate[]
   */
  protected $testEntities = [];
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'content_translation',
    'entity_test_update',
    'language',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->entityDefinitionUpdateManager = $this->container
      ->get('entity.definition_update_manager');
    $this->lastInstalledSchemaRepository = $this->container
      ->get('entity.last_installed_schema.repository');
    $this->installedStorageSchema = $this->container
      ->get('keyvalue')
      ->get('entity.storage_schema.sql');
    $this->entityTypeManager = $this->container
      ->get('entity_type.manager');
    $this->entityFieldManager = $this->container
      ->get('entity_field.manager');
    $this->database = $this->container
      ->get('database');
    // Add a non-revisionable bundle field to test revision field table
    // handling.
    $this->addBundleField('string', FALSE, TRUE);
    // The 'changed' field type has a special behavior because it updates itself
    // automatically if any of the other field values of an entity have been
    // updated, so add it to the entity type that is being tested in order to
    // provide test coverage for this special case.
    $fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'))
      ->setDescription(t('The time that the content block was last edited.'))
      ->setTranslatable(TRUE)
      ->setRevisionable(TRUE);
    $this->state
      ->set('entity_test_update.additional_base_field_definitions', $fields);
    $this->installEntitySchema($this->entityTypeId);
    // Enable an additional language.
    ConfigurableLanguage::createFromLangcode('ro')->save();
    // Force the update function to convert one entity at a time.
    $settings = Settings::getAll();
    $settings['entity_update_batch_size'] = 1;
    new Settings($settings);
  }
  
  /**
   * Generates test entities for the 'entity_test_update' entity type.
   *
   * @param bool $revisionable
   *   Whether the entity type is revisionable or not.
   * @param bool $translatable
   *   Whether the entity type is translatable or not.
   */
  protected function insertData($revisionable, $translatable) {
    // Add three test entities in order to make the "data copy" step run at
    // least three times.
    /** @var \Drupal\Core\Entity\TranslatableRevisionableStorageInterface|\Drupal\Core\Entity\EntityStorageInterface $storage */
    $storage = $this->entityTypeManager
      ->getStorage($this->entityTypeId);
    $next_id = $storage->getQuery()
      ->accessCheck(FALSE)
      ->count()
      ->execute() + 1;
    // Create test entities with two translations and two revisions.
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    for ($i = $next_id; $i <= $next_id + 2; $i++) {
      $entity = $storage->create([
        'id' => $i,
        'type' => 'test_bundle',
        'name' => 'test entity - ' . $i . ' - en',
        'new_bundle_field' => 'bundle field - ' . $i . ' - en',
        'test_multiple_properties' => [
          'value1' => 'shared table - ' . $i . ' - value 1 - en',
          'value2' => 'shared table - ' . $i . ' - value 2 - en',
        ],
        'test_multiple_properties_multiple_values' => [
          [
            'value1' => 'dedicated table - ' . $i . ' - delta 0 - value 1 - en',
            'value2' => 'dedicated table - ' . $i . ' - delta 0 - value 2 - en',
          ],
          [
            'value1' => 'dedicated table - ' . $i . ' - delta 1 - value 1 - en',
            'value2' => 'dedicated table - ' . $i . ' - delta 1 - value 2 - en',
          ],
        ],
      ]);
      $entity->save();
      if ($translatable) {
        $translation = $entity->addTranslation('ro', [
          'name' => 'test entity - ' . $i . ' - ro',
          'new_bundle_field' => 'bundle field - ' . $i . ' - ro',
          'test_multiple_properties' => [
            'value1' => 'shared table - ' . $i . ' - value 1 - ro',
            'value2' => 'shared table - ' . $i . ' - value 2 - ro',
          ],
          'test_multiple_properties_multiple_values' => [
            [
              'value1' => 'dedicated table - ' . $i . ' - delta 0 - value 1 - ro',
              'value2' => 'dedicated table - ' . $i . ' - delta 0 - value 2 - ro',
            ],
            [
              'value1' => 'dedicated table - ' . $i . ' - delta 1 - value 1 - ro',
              'value2' => 'dedicated table - ' . $i . ' - delta 1 - value 2 - ro',
            ],
          ],
        ]);
        $translation->save();
      }
      $this->testEntities[$entity->id()] = $entity;
      if ($revisionable) {
        // Create a new pending revision.
        $revision_2 = $storage->createRevision($entity, FALSE);
        $revision_2->name = 'test entity - ' . $i . ' - en - rev2';
        $revision_2->new_bundle_field = 'bundle field - ' . $i . ' - en - rev2';
        $revision_2->test_multiple_properties->value1 = 'shared table - ' . $i . ' - value 1 - en - rev2';
        $revision_2->test_multiple_properties->value2 = 'shared table - ' . $i . ' - value 2 - en - rev2';
        $revision_2->test_multiple_properties_multiple_values[0]->value1 = 'dedicated table - ' . $i . ' - delta 0 - value 1 - en - rev2';
        $revision_2->test_multiple_properties_multiple_values[0]->value2 = 'dedicated table - ' . $i . ' - delta 0 - value 2 - en - rev2';
        $revision_2->test_multiple_properties_multiple_values[1]->value1 = 'dedicated table - ' . $i . ' - delta 1 - value 1 - en - rev2';
        $revision_2->test_multiple_properties_multiple_values[1]->value2 = 'dedicated table - ' . $i . ' - delta 1 - value 2 - en - rev2';
        $revision_2->save();
        if ($translatable) {
          $revision_2_translation = $storage->createRevision($entity->getTranslation('ro'), FALSE);
          $revision_2_translation->name = 'test entity - ' . $i . ' - ro - rev2';
          $revision_2->new_bundle_field = 'bundle field - ' . $i . ' - ro - rev2';
          $revision_2->test_multiple_properties->value1 = 'shared table - ' . $i . ' - value 1 - ro - rev2';
          $revision_2->test_multiple_properties->value2 = 'shared table - ' . $i . ' - value 2 - ro - rev2';
          $revision_2_translation->test_multiple_properties_multiple_values[0]->value1 = 'dedicated table - ' . $i . ' - delta 0 - value 1 - ro - rev2';
          $revision_2_translation->test_multiple_properties_multiple_values[0]->value2 = 'dedicated table - ' . $i . ' - delta 0 - value 2 - ro - rev2';
          $revision_2_translation->test_multiple_properties_multiple_values[1]->value1 = 'dedicated table - ' . $i . ' - delta 1 - value 1 - ro - rev2';
          $revision_2_translation->test_multiple_properties_multiple_values[1]->value2 = 'dedicated table - ' . $i . ' - delta 1 - value 2 - ro - rev2';
          $revision_2_translation->save();
        }
      }
    }
  }
  
  /**
   * Asserts test entity data after a fieldable entity type update.
   *
   * @param bool $revisionable
   *   Whether the entity type was revisionable prior to the update.
   * @param bool $translatable
   *   Whether the entity type was translatable prior to the update.
   *
   * @internal
   */
  protected function assertEntityData(bool $revisionable, bool $translatable) : void {
    $entities = $this->entityTypeManager
      ->getStorage($this->entityTypeId)
      ->loadMultiple();
    $this->assertCount(3, $entities);
    foreach ($entities as $entity_id => $entity) {
      /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
      $this->assertEquals("test entity - {$entity->id()} - en", $entity->label());
      $this->assertEquals("bundle field - {$entity->id()} - en", $entity->new_bundle_field->value);
      $this->assertEquals("shared table - {$entity->id()} - value 1 - en", $entity->test_multiple_properties->value1);
      $this->assertEquals("shared table - {$entity->id()} - value 2 - en", $entity->test_multiple_properties->value2);
      $this->assertEquals("dedicated table - {$entity->id()} - delta 0 - value 1 - en", $entity->test_multiple_properties_multiple_values[0]->value1);
      $this->assertEquals("dedicated table - {$entity->id()} - delta 0 - value 2 - en", $entity->test_multiple_properties_multiple_values[0]->value2);
      $this->assertEquals("dedicated table - {$entity->id()} - delta 1 - value 1 - en", $entity->test_multiple_properties_multiple_values[1]->value1);
      $this->assertEquals("dedicated table - {$entity->id()} - delta 1 - value 2 - en", $entity->test_multiple_properties_multiple_values[1]->value2);
      if ($translatable) {
        $translation = $entity->getTranslation('ro');
        $this->assertEquals("test entity - {$translation->id()} - ro", $translation->label());
        $this->assertEquals("bundle field - {$entity->id()} - ro", $translation->new_bundle_field->value);
        $this->assertEquals("shared table - {$translation->id()} - value 1 - ro", $translation->test_multiple_properties->value1);
        $this->assertEquals("shared table - {$translation->id()} - value 2 - ro", $translation->test_multiple_properties->value2);
        $this->assertEquals("dedicated table - {$translation->id()} - delta 0 - value 1 - ro", $translation->test_multiple_properties_multiple_values[0]->value1);
        $this->assertEquals("dedicated table - {$translation->id()} - delta 0 - value 2 - ro", $translation->test_multiple_properties_multiple_values[0]->value2);
        $this->assertEquals("dedicated table - {$translation->id()} - delta 1 - value 1 - ro", $translation->test_multiple_properties_multiple_values[1]->value1);
        $this->assertEquals("dedicated table - {$translation->id()} - delta 1 - value 2 - ro", $translation->test_multiple_properties_multiple_values[1]->value2);
      }
    }
    if ($revisionable) {
      $revisions_result = $this->entityTypeManager
        ->getStorage($this->entityTypeId)
        ->getQuery()
        ->accessCheck(FALSE)
        ->allRevisions()
        ->execute();
      $revisions = $this->entityTypeManager
        ->getStorage($this->entityTypeId)
        ->loadMultipleRevisions(array_keys($revisions_result));
      $this->assertCount(6, $revisions);
      foreach ($revisions as $revision) {
        /** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
        $revision_label = $revision->isDefaultRevision() ? NULL : ' - rev2';
        $this->assertEquals("test entity - {$revision->id()} - en{$revision_label}", $revision->label());
        $this->assertEquals("bundle field - {$revision->id()} - en{$revision_label}", $revision->new_bundle_field->value);
        $this->assertEquals("shared table - {$revision->id()} - value 1 - en{$revision_label}", $revision->test_multiple_properties->value1);
        $this->assertEquals("shared table - {$revision->id()} - value 2 - en{$revision_label}", $revision->test_multiple_properties->value2);
        $this->assertEquals("dedicated table - {$revision->id()} - delta 0 - value 1 - en{$revision_label}", $revision->test_multiple_properties_multiple_values[0]->value1);
        $this->assertEquals("dedicated table - {$revision->id()} - delta 0 - value 2 - en{$revision_label}", $revision->test_multiple_properties_multiple_values[0]->value2);
        $this->assertEquals("dedicated table - {$revision->id()} - delta 1 - value 1 - en{$revision_label}", $revision->test_multiple_properties_multiple_values[1]->value1);
        $this->assertEquals("dedicated table - {$revision->id()} - delta 1 - value 2 - en{$revision_label}", $revision->test_multiple_properties_multiple_values[1]->value2);
        if ($translatable) {
          $translation = $revision->getTranslation('ro');
          $this->assertEquals("test entity - {$translation->id()} - ro{$revision_label}", $translation->label());
          $this->assertEquals("bundle field - {$entity->id()} - ro{$revision_label}", $translation->new_bundle_field->value);
          $this->assertEquals("shared table - {$revision->id()} - value 1 - ro{$revision_label}", $translation->test_multiple_properties->value1);
          $this->assertEquals("shared table - {$revision->id()} - value 2 - ro{$revision_label}", $translation->test_multiple_properties->value2);
          $this->assertEquals("dedicated table - {$translation->id()} - delta 0 - value 1 - ro{$revision_label}", $translation->test_multiple_properties_multiple_values[0]->value1);
          $this->assertEquals("dedicated table - {$translation->id()} - delta 0 - value 2 - ro{$revision_label}", $translation->test_multiple_properties_multiple_values[0]->value2);
          $this->assertEquals("dedicated table - {$translation->id()} - delta 1 - value 1 - ro{$revision_label}", $translation->test_multiple_properties_multiple_values[1]->value1);
          $this->assertEquals("dedicated table - {$translation->id()} - delta 1 - value 2 - ro{$revision_label}", $translation->test_multiple_properties_multiple_values[1]->value2);
        }
      }
    }
  }
  
  /**
   * Asserts revisionable and/or translatable characteristics of an entity type.
   *
   * @param bool $revisionable
   *   Whether the entity type is revisionable or not.
   * @param bool $translatable
   *   Whether the entity type is translatable or not.
   * @param bool $new_base_field
   *   (optional) Whether a new base field was added as part of the update.
   *   Defaults to FALSE.
   *
   * @internal
   */
  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);
  }
  
  /**
   * Asserts the revisionable characteristics of an entity type.
   *
   * @internal
   */
  protected function assertRevisionable() : void {
    /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
    $entity_type = $this->entityDefinitionUpdateManager
      ->getEntityType($this->entityTypeId);
    $this->assertTrue($entity_type->isRevisionable());
    // Check that the required field definitions of a revisionable entity type
    // exists and are stored in the correct tables.
    $revision_key = $entity_type->getKey('revision');
    $revision_default_key = $entity_type->getRevisionMetadataKey('revision_default');
    $revision_field = $this->entityDefinitionUpdateManager
      ->getFieldStorageDefinition($revision_key, $entity_type->id());
    $revision_default_field = $this->entityDefinitionUpdateManager
      ->getFieldStorageDefinition($revision_default_key, $entity_type->id());
    $this->assertNotNull($revision_field);
    $this->assertNotNull($revision_default_field);
    $database_schema = $this->database
      ->schema();
    $base_table = $entity_type->getBaseTable();
    $revision_table = $entity_type->getRevisionTable();
    $this->assertTrue($database_schema->tableExists($revision_table));
    $this->assertTrue($database_schema->fieldExists($base_table, $revision_key));
    $this->assertTrue($database_schema->fieldExists($revision_table, $revision_key));
    $this->assertFalse($database_schema->fieldExists($base_table, $revision_default_key));
    $this->assertTrue($database_schema->fieldExists($revision_table, $revision_default_key));
    // Also check the revision metadata keys, if they exist.
    foreach ([
      'revision_log_message',
      'revision_user',
      'revision_created',
    ] as $key) {
      if ($revision_metadata_key = $entity_type->getRevisionMetadataKey($key)) {
        $revision_metadata_field = $this->entityDefinitionUpdateManager
          ->getFieldStorageDefinition($revision_metadata_key, $entity_type->id());
        $this->assertNotNull($revision_metadata_field);
        $this->assertFalse($database_schema->fieldExists($base_table, $revision_metadata_key));
        $this->assertTrue($database_schema->fieldExists($revision_table, $revision_metadata_key));
      }
    }
  }
  
  /**
   * Asserts the translatable characteristics of an entity type.
   *
   * @internal
   */
  protected function assertTranslatable() : void {
    /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
    $entity_type = $this->entityDefinitionUpdateManager
      ->getEntityType($this->entityTypeId);
    $this->assertTrue($entity_type->isTranslatable());
    // Check that the required field definitions of a translatable entity type
    // exists and are stored in the correct tables.
    $langcode_key = $entity_type->getKey('langcode');
    $default_langcode_key = $entity_type->getKey('default_langcode');
    $langcode_field = $this->entityDefinitionUpdateManager
      ->getFieldStorageDefinition($langcode_key, $entity_type->id());
    $default_langcode_field = $this->entityDefinitionUpdateManager
      ->getFieldStorageDefinition($default_langcode_key, $entity_type->id());
    $this->assertNotNull($langcode_field);
    $this->assertNotNull($default_langcode_field);
    $database_schema = $this->database
      ->schema();
    $base_table = $entity_type->getBaseTable();
    $data_table = $entity_type->getDataTable();
    $this->assertTrue($database_schema->tableExists($data_table));
    $this->assertTrue($database_schema->fieldExists($base_table, $langcode_key));
    $this->assertTrue($database_schema->fieldExists($data_table, $langcode_key));
    $this->assertFalse($database_schema->fieldExists($base_table, $default_langcode_key));
    $this->assertTrue($database_schema->fieldExists($data_table, $default_langcode_key));
  }
  
  /**
   * Asserts the revisionable / translatable characteristics of an entity type.
   *
   * @internal
   */
  protected function assertRevisionableAndTranslatable() : void {
    $this->assertRevisionable();
    $this->assertTranslatable();
    // Check that the required field definitions of a revisionable and
    // translatable entity type exists and are stored in the correct tables.
    /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
    $entity_type = $this->entityDefinitionUpdateManager
      ->getEntityType($this->entityTypeId);
    $langcode_key = $entity_type->getKey('langcode');
    $revision_translation_affected_key = $entity_type->getKey('revision_translation_affected');
    $revision_translation_affected_field = $this->entityDefinitionUpdateManager
      ->getFieldStorageDefinition($revision_translation_affected_key, $entity_type->id());
    $this->assertNotNull($revision_translation_affected_field);
    $database_schema = $this->database
      ->schema();
    $base_table = $entity_type->getBaseTable();
    $data_table = $entity_type->getDataTable();
    $revision_table = $entity_type->getRevisionTable();
    $revision_data_table = $entity_type->getRevisionDataTable();
    $this->assertTrue($database_schema->tableExists($revision_data_table));
    $this->assertTrue($database_schema->fieldExists($base_table, $langcode_key));
    $this->assertTrue($database_schema->fieldExists($data_table, $langcode_key));
    $this->assertTrue($database_schema->fieldExists($revision_table, $langcode_key));
    $this->assertTrue($database_schema->fieldExists($revision_data_table, $langcode_key));
    $this->assertFalse($database_schema->fieldExists($base_table, $revision_translation_affected_key));
    $this->assertFalse($database_schema->fieldExists($revision_table, $revision_translation_affected_key));
    $this->assertTrue($database_schema->fieldExists($data_table, $revision_translation_affected_key));
    $this->assertTrue($database_schema->fieldExists($revision_data_table, $revision_translation_affected_key));
    // Also check the revision metadata keys, if they exist.
    foreach ([
      'revision_log_message',
      'revision_user',
      'revision_created',
    ] as $key) {
      if ($revision_metadata_key = $entity_type->getRevisionMetadataKey($key)) {
        $revision_metadata_field = $this->entityDefinitionUpdateManager
          ->getFieldStorageDefinition($revision_metadata_key, $entity_type->id());
        $this->assertNotNull($revision_metadata_field);
        $this->assertFalse($database_schema->fieldExists($base_table, $revision_metadata_key));
        $this->assertTrue($database_schema->fieldExists($revision_table, $revision_metadata_key));
        $this->assertFalse($database_schema->fieldExists($data_table, $revision_metadata_key));
        $this->assertFalse($database_schema->fieldExists($revision_data_table, $revision_metadata_key));
      }
    }
  }
  
  /**
   * Asserts that an entity type is neither revisionable nor translatable.
   *
   * @internal
   */
  protected function assertNonRevisionableAndNonTranslatable() : void {
    /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
    $entity_type = $this->entityDefinitionUpdateManager
      ->getEntityType($this->entityTypeId);
    $this->assertFalse($entity_type->isRevisionable());
    $this->assertFalse($entity_type->isTranslatable());
    $database_schema = $this->database
      ->schema();
    $this->assertTrue($database_schema->tableExists($entity_type->getBaseTable()));
    $this->assertFalse($database_schema->tableExists($entity_type->getDataTable()));
    $this->assertFalse($database_schema->tableExists($entity_type->getRevisionTable()));
    $this->assertFalse($database_schema->tableExists($entity_type->getRevisionDataTable()));
  }
  
  /**
   * Asserts that the bundle field schema is correct.
   *
   * @param bool $revisionable
   *   Whether the entity type is revisionable or not.
   *
   * @internal
   */
  protected function assertBundleFieldSchema(bool $revisionable) : void {
    $entity_type_id = 'entity_test_update';
    $field_storage_definition = $this->entityFieldManager
      ->getFieldStorageDefinitions($entity_type_id)['new_bundle_field'];
    $database_schema = $this->database
      ->schema();
    /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
    $table_mapping = $this->entityTypeManager
      ->getStorage($entity_type_id)
      ->getTableMapping();
    $this->assertTrue($database_schema->tableExists($table_mapping->getDedicatedDataTableName($field_storage_definition)));
    if ($revisionable) {
      $this->assertTrue($database_schema->tableExists($table_mapping->getDedicatedRevisionTableName($field_storage_definition)));
    }
  }
  
  /**
   * Asserts that the backup tables have been kept after a successful update.
   *
   * @internal
   */
  protected function assertBackupTables() : void {
    $backups = \Drupal::keyValue('entity.update_backup')->getAll();
    $backup = reset($backups);
    $schema = $this->database
      ->schema();
    foreach ($backup['table_mapping']->getTableNames() as $table_name) {
      $this->assertTrue($schema->tableExists($table_name));
    }
  }
  
  /**
   * Tests that a failed entity schema update preserves the existing data.
   */
  public function testFieldableEntityTypeUpdatesErrorHandling() : void {
    $schema = $this->database
      ->schema();
    // First, convert the entity type to be translatable for better coverage and
    // insert some initial data.
    $entity_type = $this->getUpdatedEntityTypeDefinition(FALSE, TRUE);
    $field_storage_definitions = $this->getUpdatedFieldStorageDefinitions(FALSE, TRUE);
    $this->entityDefinitionUpdateManager
      ->updateFieldableEntityType($entity_type, $field_storage_definitions);
    $this->assertEntityTypeSchema(FALSE, TRUE);
    $this->insertData(FALSE, TRUE);
    $tables = $schema->findTables('old_%');
    $this->assertCount(4, $tables);
    foreach ($tables as $table) {
      $schema->dropTable($table);
    }
    $original_entity_type = $this->lastInstalledSchemaRepository
      ->getLastInstalledDefinition('entity_test_update');
    $original_storage_definitions = $this->lastInstalledSchemaRepository
      ->getLastInstalledFieldStorageDefinitions('entity_test_update');
    $original_entity_schema_data = $this->installedStorageSchema
      ->get('entity_test_update.entity_schema_data', []);
    $original_field_schema_data = [];
    foreach ($original_storage_definitions as $storage_definition) {
      $original_field_schema_data[$storage_definition->getName()] = $this->installedStorageSchema
        ->get('entity_test_update.field_schema_data.' . $storage_definition->getName(), []);
    }
    // Check that entity type is not revisionable prior to running the update
    // process.
    $this->assertFalse($entity_type->isRevisionable());
    // Make the update throw an exception during the entity save process.
    \Drupal::state()->set('entity_test_update.throw_exception', TRUE);
    $this->expectException(EntityStorageException::class);
    $this->expectExceptionMessage('The entity update process failed while processing the entity type entity_test_update, ID: 1.');
    try {
      $updated_entity_type = $this->getUpdatedEntityTypeDefinition(TRUE, TRUE);
      $updated_field_storage_definitions = $this->getUpdatedFieldStorageDefinitions(TRUE, TRUE);
      // Simulate a batch run since we are converting the entities one by one.
      $sandbox = [];
      do {
        $this->entityDefinitionUpdateManager
          ->updateFieldableEntityType($updated_entity_type, $updated_field_storage_definitions, $sandbox);
      } while ($sandbox['#finished'] != 1);
    } catch (EntityStorageException $e) {
      throw $e;
    } finally {
      $this->assertSame('Peekaboo!', $e->getPrevious()
        ->getMessage());
      // Check that the last installed entity type definition is kept as
      // non-revisionable.
      $new_entity_type = $this->lastInstalledSchemaRepository
        ->getLastInstalledDefinition('entity_test_update');
      $this->assertFalse($new_entity_type->isRevisionable(), 'The entity type is kept unchanged.');
      // Check that the last installed field storage definitions did not change by
      // looking at the 'langcode' field, which is updated automatically.
      $new_storage_definitions = $this->lastInstalledSchemaRepository
        ->getLastInstalledFieldStorageDefinitions('entity_test_update');
      $langcode_key = $original_entity_type->getKey('langcode');
      $this->assertEquals($original_storage_definitions[$langcode_key]->isRevisionable(), $new_storage_definitions[$langcode_key]->isRevisionable(), "The 'langcode' field is kept unchanged.");
      /** @var \Drupal\Core\Entity\Sql\SqlEntityStorageInterface $storage */
      $storage = $this->entityTypeManager
        ->getStorage('entity_test_update');
      $table_mapping = $storage->getTableMapping();
      // Check that installed storage schema did not change.
      $new_entity_schema_data = $this->installedStorageSchema
        ->get('entity_test_update.entity_schema_data', []);
      $this->assertEquals($original_entity_schema_data, $new_entity_schema_data);
      foreach ($new_storage_definitions as $storage_definition) {
        $new_field_schema_data[$storage_definition->getName()] = $this->installedStorageSchema
          ->get('entity_test_update.field_schema_data.' . $storage_definition->getName(), []);
      }
      $this->assertEquals($original_field_schema_data, $new_field_schema_data);
      // Check that temporary tables have been removed.
      $tables = $schema->findTables('tmp_%');
      $this->assertCount(0, $tables);
      $current_table_names = $storage->getCustomTableMapping($original_entity_type, $original_storage_definitions)
        ->getTableNames();
      foreach ($current_table_names as $table_name) {
        $this->assertTrue($schema->tableExists($table_name));
      }
      // Check that backup tables do not exist anymore, since they were
      // restored/renamed.
      $tables = $schema->findTables('old_%');
      $this->assertCount(0, $tables);
      // Check that the original tables still exist and their data is intact.
      $this->assertTrue($schema->tableExists('entity_test_update'));
      $this->assertTrue($schema->tableExists('entity_test_update_data'));
      // Check that the revision tables have not been created.
      $this->assertFalse($schema->tableExists('entity_test_update_revision'));
      $this->assertFalse($schema->tableExists('entity_test_update_revision_data'));
      $base_table_count = $this->database
        ->select('entity_test_update')
        ->countQuery()
        ->execute()
        ->fetchField();
      $this->assertEquals(3, $base_table_count);
      $data_table_count = $this->database
        ->select('entity_test_update_data')
        ->countQuery()
        ->execute()
        ->fetchField();
      // There are two records for each entity, one for English and one for
      // Romanian.
      $this->assertEquals(6, $data_table_count);
      $base_table_row = $this->database
        ->select('entity_test_update')
        ->fields('entity_test_update')
        ->condition('id', 1, '=')
        ->condition('langcode', 'en', '=')
        ->execute()
        ->fetchAllAssoc('id');
      $this->assertEquals($this->testEntities[1]
        ->uuid(), $base_table_row[1]->uuid);
      $data_table_row = $this->database
        ->select('entity_test_update_data')
        ->fields('entity_test_update_data')
        ->condition('id', 1, '=')
        ->condition('langcode', 'en', '=')
        ->execute()
        ->fetchAllAssoc('id');
      $this->assertEquals('test entity - 1 - en', $data_table_row[1]->name);
      $this->assertEquals('shared table - 1 - value 1 - en', $data_table_row[1]->test_multiple_properties__value1);
      $this->assertEquals('shared table - 1 - value 2 - en', $data_table_row[1]->test_multiple_properties__value2);
      $data_table_row = $this->database
        ->select('entity_test_update_data')
        ->fields('entity_test_update_data')
        ->condition('id', 1, '=')
        ->condition('langcode', 'ro', '=')
        ->execute()
        ->fetchAllAssoc('id');
      $this->assertEquals('test entity - 1 - ro', $data_table_row[1]->name);
      $this->assertEquals('shared table - 1 - value 1 - ro', $data_table_row[1]->test_multiple_properties__value1);
      $this->assertEquals('shared table - 1 - value 2 - ro', $data_table_row[1]->test_multiple_properties__value2);
      $dedicated_table_name = $table_mapping->getFieldTableName('test_multiple_properties_multiple_values');
      $dedicated_table_row = $this->database
        ->select($dedicated_table_name)
        ->fields($dedicated_table_name)
        ->condition('entity_id', 1, '=')
        ->condition('langcode', 'en', '=')
        ->execute()
        ->fetchAllAssoc('delta');
      $this->assertEquals('dedicated table - 1 - delta 0 - value 1 - en', $dedicated_table_row[0]->test_multiple_properties_multiple_values_value1);
      $this->assertEquals('dedicated table - 1 - delta 0 - value 2 - en', $dedicated_table_row[0]->test_multiple_properties_multiple_values_value2);
      $this->assertEquals('dedicated table - 1 - delta 1 - value 1 - en', $dedicated_table_row[1]->test_multiple_properties_multiple_values_value1);
      $this->assertEquals('dedicated table - 1 - delta 1 - value 2 - en', $dedicated_table_row[1]->test_multiple_properties_multiple_values_value2);
      $dedicated_table_row = $this->database
        ->select($dedicated_table_name)
        ->fields($dedicated_table_name)
        ->condition('entity_id', 1, '=')
        ->condition('langcode', 'ro', '=')
        ->execute()
        ->fetchAllAssoc('delta');
      $this->assertEquals('dedicated table - 1 - delta 0 - value 1 - ro', $dedicated_table_row[0]->test_multiple_properties_multiple_values_value1);
      $this->assertEquals('dedicated table - 1 - delta 0 - value 2 - ro', $dedicated_table_row[0]->test_multiple_properties_multiple_values_value2);
      $this->assertEquals('dedicated table - 1 - delta 1 - value 1 - ro', $dedicated_table_row[1]->test_multiple_properties_multiple_values_value1);
      $this->assertEquals('dedicated table - 1 - delta 1 - value 2 - ro', $dedicated_table_row[1]->test_multiple_properties_multiple_values_value2);
    }
  }
  
  /**
   * Tests the removal of the backup tables after a successful update.
   */
  public function testFieldableEntityTypeUpdatesRemoveBackupTables() : void {
    $schema = $this->database
      ->schema();
    // Convert the entity type to be revisionable.
    $entity_type = $this->getUpdatedEntityTypeDefinition(TRUE, FALSE);
    $field_storage_definitions = $this->getUpdatedFieldStorageDefinitions(TRUE, FALSE);
    $this->entityDefinitionUpdateManager
      ->updateFieldableEntityType($entity_type, $field_storage_definitions);
    // Check that backup tables are kept by default.
    $tables = $schema->findTables('old_%');
    $this->assertCount(4, $tables);
    foreach ($tables as $table) {
      $schema->dropTable($table);
    }
    // Make the entity update process drop the backup tables after a successful
    // update.
    $settings = Settings::getAll();
    $settings['entity_update_backup'] = FALSE;
    new Settings($settings);
    $entity_type = $this->getUpdatedEntityTypeDefinition(TRUE, TRUE);
    $field_storage_definitions = $this->getUpdatedFieldStorageDefinitions(TRUE, TRUE);
    $this->entityDefinitionUpdateManager
      ->updateFieldableEntityType($entity_type, $field_storage_definitions);
    // Check that backup tables have been dropped.
    $tables = $schema->findTables('old_%');
    $this->assertCount(0, $tables);
  }
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Member alias | Overriden Title | Overrides | 
|---|---|---|---|---|---|---|---|
| AssertContentTrait::$content | protected | property | The current raw content. | ||||
| AssertContentTrait::$drupalSettings | protected | property | The drupalSettings value from the current raw $content. | ||||
| AssertContentTrait::$elements | protected | property | The XML structure parsed from the current raw $content. | 1 | |||
| AssertContentTrait::$plainTextContent | protected | property | The plain-text content of raw $content (text nodes). | ||||
| AssertContentTrait::assertEscaped | protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | ||||
| AssertContentTrait::assertField | protected | function | Asserts that a field exists with the given name or ID. | ||||
| AssertContentTrait::assertFieldById | protected | function | Asserts that a field exists with the given ID and value. | ||||
| AssertContentTrait::assertFieldByName | protected | function | Asserts that a field exists with the given name and value. | ||||
| AssertContentTrait::assertFieldByXPath | protected | function | Asserts that a field exists in the current page by the given XPath. | ||||
| AssertContentTrait::assertFieldChecked | protected | function | Asserts that a checkbox field in the current page is checked. | ||||
| AssertContentTrait::assertFieldsByValue | protected | function | Asserts that a field exists in the current page with a given Xpath result. | ||||
| AssertContentTrait::assertLink | protected | function | Passes if a link with the specified label is found. | ||||
| AssertContentTrait::assertLinkByHref | protected | function | Passes if a link containing a given href (part) is found. | ||||
| AssertContentTrait::assertNoDuplicateIds | protected | function | Asserts that each HTML ID is used for just a single element. | ||||
| AssertContentTrait::assertNoEscaped | protected | function | Passes if raw text IS NOT found escaped on loaded page, fail otherwise. | ||||
| AssertContentTrait::assertNoField | protected | function | Asserts that a field does not exist with the given name or ID. | ||||
| AssertContentTrait::assertNoFieldById | protected | function | Asserts that a field does not exist with the given ID and value. | ||||
| AssertContentTrait::assertNoFieldByName | protected | function | Asserts that a field does not exist with the given name and value. | ||||
| AssertContentTrait::assertNoFieldByXPath | protected | function | Asserts that a field does not exist or its value does not match, by XPath. | ||||
| AssertContentTrait::assertNoFieldChecked | protected | function | Asserts that a checkbox field in the current page is not checked. | ||||
| AssertContentTrait::assertNoLink | protected | function | Passes if a link with the specified label is not found. | ||||
| AssertContentTrait::assertNoLinkByHref | protected | function | Passes if a link containing a given href (part) is not found. | ||||
| AssertContentTrait::assertNoLinkByHrefInMainRegion | protected | function | Passes if a link containing a given href is not found in the main region. | ||||
| AssertContentTrait::assertNoOption | protected | function | Asserts that a select option in the current page does not exist. | ||||
| AssertContentTrait::assertNoOptionSelected | protected | function | Asserts that a select option in the current page is not checked. | ||||
| AssertContentTrait::assertNoPattern | protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | ||||
| AssertContentTrait::assertNoRaw | protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | ||||
| AssertContentTrait::assertNoText | protected | function | Passes if the page (with HTML stripped) does not contains the text. | ||||
| AssertContentTrait::assertNoTitle | protected | function | Pass if the page title is not the given string. | ||||
| AssertContentTrait::assertNoUniqueText | protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | ||||
| AssertContentTrait::assertOption | protected | function | Asserts that a select option in the current page exists. | ||||
| AssertContentTrait::assertOptionByText | protected | function | Asserts that a select option with the visible text exists. | ||||
| AssertContentTrait::assertOptionSelected | protected | function | Asserts that a select option in the current page is checked. | ||||
| AssertContentTrait::assertOptionSelectedWithDrupalSelector | protected | function | Asserts that a select option in the current page is checked. | ||||
| AssertContentTrait::assertOptionWithDrupalSelector | protected | function | Asserts that a select option in the current page exists. | ||||
| AssertContentTrait::assertPattern | protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | ||||
| AssertContentTrait::assertRaw | protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | ||||
| AssertContentTrait::assertText | protected | function | Passes if the page (with HTML stripped) contains the text. | ||||
| AssertContentTrait::assertTextHelper | protected | function | Helper for assertText and assertNoText. | ||||
| AssertContentTrait::assertTextPattern | protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | ||||
| AssertContentTrait::assertThemeOutput | protected | function | Asserts themed output. | ||||
| AssertContentTrait::assertTitle | protected | function | Pass if the page title is the given string. | ||||
| AssertContentTrait::assertUniqueText | protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | ||||
| AssertContentTrait::assertUniqueTextHelper | protected | function | Helper for assertUniqueText and assertNoUniqueText. | ||||
| AssertContentTrait::buildXPathQuery | protected | function | Builds an XPath query. | ||||
| AssertContentTrait::constructFieldXpath | protected | function | Helper: Constructs an XPath for the given set of attributes and value. | ||||
| AssertContentTrait::cssSelect | protected | function | Searches elements using a CSS selector in the raw content. | ||||
| AssertContentTrait::getAllOptions | protected | function | Get all option elements, including nested options, in a select. | ||||
| AssertContentTrait::getDrupalSettings | protected | function | Gets the value of drupalSettings for the currently-loaded page. | ||||
| AssertContentTrait::getRawContent | protected | function | Gets the current raw content. | ||||
| AssertContentTrait::getSelectedItem | protected | function | Get the selected value from a select field. | ||||
| AssertContentTrait::getTextContent | protected | function | Retrieves the plain-text content from the current raw content. | ||||
| AssertContentTrait::parse | protected | function | Parse content returned from curlExec using DOM and SimpleXML. | ||||
| AssertContentTrait::removeWhiteSpace | protected | function | Removes all white-space between HTML tags from the raw content. | ||||
| AssertContentTrait::setDrupalSettings | protected | function | Sets the value of drupalSettings for the currently-loaded page. | ||||
| AssertContentTrait::setRawContent | protected | function | Sets the raw content (e.g. HTML). | ||||
| AssertContentTrait::xpath | protected | function | Performs an xpath search on the contents of the internal browser. | ||||
| ConfigTestTrait::configImporter | protected | function | Returns a ConfigImporter object to import test configuration. | ||||
| ConfigTestTrait::copyConfig | protected | function | Copies configuration objects from source storage to target storage. | ||||
| EntityDefinitionTestTrait::addBaseField | protected | function | Adds a new base field to the 'entity_test_update' entity type. | ||||
| EntityDefinitionTestTrait::addBaseFieldIndex | protected | function | Adds a single-field index to the base field. | ||||
| EntityDefinitionTestTrait::addBundleField | protected | function | Adds a new bundle field to the 'entity_test_update' entity type. | ||||
| EntityDefinitionTestTrait::addEntityIndex | protected | function | Adds an index to the 'entity_test_update' entity type's base table. | ||||
| EntityDefinitionTestTrait::addLongNameBaseField | protected | function | Adds a long-named base field to the 'entity_test_update' entity type. | ||||
| EntityDefinitionTestTrait::addRevisionableBaseField | protected | function | Adds a new revisionable base field to the 'entity_test_update' entity type. | ||||
| EntityDefinitionTestTrait::applyEntityUpdates | protected | function | Applies all the detected valid changes. | ||||
| EntityDefinitionTestTrait::deleteEntityType | protected | function | Removes the entity type. | ||||
| EntityDefinitionTestTrait::doEntityUpdate | protected | function | Performs an entity type definition update. | ||||
| EntityDefinitionTestTrait::doFieldUpdate | protected | function | Performs a field storage definition update. | ||||
| EntityDefinitionTestTrait::enableNewEntityType | protected | function | Enables a new entity type definition. | ||||
| EntityDefinitionTestTrait::getUpdatedEntityTypeDefinition | protected | function | Returns an entity type definition, possibly updated to be rev or mul. | ||||
| EntityDefinitionTestTrait::getUpdatedFieldStorageDefinitions | protected | function | Returns the required rev / mul field definitions for an entity type. | ||||
| EntityDefinitionTestTrait::makeBaseFieldEntityKey | protected | function | Promotes a field to an entity key. | ||||
| EntityDefinitionTestTrait::modifyBaseField | protected | function | Modifies the new base field from 'string' to 'text'. | ||||
| EntityDefinitionTestTrait::modifyBundleField | protected | function | Modifies the new bundle field from 'string' to 'text'. | ||||
| EntityDefinitionTestTrait::removeBaseField | protected | function | Removes the new base field from the 'entity_test_update' entity type. | ||||
| EntityDefinitionTestTrait::removeBaseFieldIndex | protected | function | Removes the index added in addBaseFieldIndex(). | ||||
| EntityDefinitionTestTrait::removeBundleField | protected | function | Removes the new bundle field from the 'entity_test_update' entity type. | ||||
| EntityDefinitionTestTrait::removeEntityIndex | protected | function | Removes the index added in addEntityIndex(). | ||||
| EntityDefinitionTestTrait::renameBaseTable | protected | function | Renames the base table to 'entity_test_update_new'. | ||||
| EntityDefinitionTestTrait::renameDataTable | protected | function | Renames the data table to 'entity_test_update_data_new'. | ||||
| EntityDefinitionTestTrait::renameRevisionBaseTable | protected | function | Renames the revision table to 'entity_test_update_revision_new'. | ||||
| EntityDefinitionTestTrait::renameRevisionDataTable | protected | function | Renames the revision data table to 'entity_test_update_revision_data_new'. | ||||
| EntityDefinitionTestTrait::resetEntityType | protected | function | Resets the entity type definition. | ||||
| EntityDefinitionTestTrait::updateEntityTypeToNotRevisionable | protected | function | Updates the 'entity_test_update' entity type not revisionable. | ||||
| EntityDefinitionTestTrait::updateEntityTypeToNotTranslatable | protected | function | Updates the 'entity_test_update' entity type to not translatable. | ||||
| EntityDefinitionTestTrait::updateEntityTypeToRevisionable | protected | function | Updates the 'entity_test_update' entity type to revisionable. | ||||
| EntityDefinitionTestTrait::updateEntityTypeToRevisionableAndTranslatable | protected | function | Updates the test entity type to be revisionable and translatable. | ||||
| EntityDefinitionTestTrait::updateEntityTypeToTranslatable | protected | function | Updates the 'entity_test_update' entity type to translatable. | ||||
| EntityKernelTestBase::$generatedIds | protected | property | A list of generated identifiers. | ||||
| EntityKernelTestBase::$state | protected | property | The state service. | ||||
| EntityKernelTestBase::createUser | protected | function | Creates a user. | ||||
| EntityKernelTestBase::generateRandomEntityId | protected | function | Generates a random ID avoiding collisions. | ||||
| EntityKernelTestBase::getHooksInfo | protected | function | Returns the entity_test hook invocation info. | ||||
| EntityKernelTestBase::installModule | protected | function | Installs a module and refreshes services. | ||||
| EntityKernelTestBase::refreshServices | protected | function | Refresh services. | 1 | |||
| EntityKernelTestBase::reloadEntity | protected | function | Reloads the given entity from the storage and returns it. | ||||
| EntityKernelTestBase::uninstallModule | protected | function | Uninstalls a module and refreshes services. | ||||
| ExtensionListTestTrait::getModulePath | protected | function | Gets the path for the specified module. | ||||
| ExtensionListTestTrait::getThemePath | protected | function | Gets the path for the specified theme. | ||||
| FieldableEntityDefinitionUpdateTest::$database | protected | property | The database connection. | ||||
| FieldableEntityDefinitionUpdateTest::$entityDefinitionUpdateManager | protected | property | The entity definition update manager. | ||||
| FieldableEntityDefinitionUpdateTest::$entityFieldManager | protected | property | The entity field manager. | ||||
| FieldableEntityDefinitionUpdateTest::$entityTypeId | protected | property | The ID of the entity type used in this test. | ||||
| FieldableEntityDefinitionUpdateTest::$entityTypeManager | protected | property | The entity type manager. | Overrides EntityKernelTestBase::$entityTypeManager | |||
| FieldableEntityDefinitionUpdateTest::$installedStorageSchema | protected | property | The key-value collection for tracking installed storage schema. | ||||
| FieldableEntityDefinitionUpdateTest::$lastInstalledSchemaRepository | protected | property | The last installed schema repository service. | ||||
| FieldableEntityDefinitionUpdateTest::$modules | protected static | property | Modules to install. | Overrides EntityKernelTestBase::$modules | |||
| FieldableEntityDefinitionUpdateTest::$testEntities | protected | property | An array of entities are created during the test. | ||||
| FieldableEntityDefinitionUpdateTest::assertBackupTables | protected | function | Asserts that the backup tables have been kept after a successful update. | ||||
| FieldableEntityDefinitionUpdateTest::assertBundleFieldSchema | protected | function | Asserts that the bundle field schema is correct. | ||||
| FieldableEntityDefinitionUpdateTest::assertEntityData | protected | function | Asserts test entity data after a fieldable entity type update. | ||||
| FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema | protected | function | Asserts revisionable and/or translatable characteristics of an entity type. | ||||
| FieldableEntityDefinitionUpdateTest::assertNonRevisionableAndNonTranslatable | protected | function | Asserts that an entity type is neither revisionable nor translatable. | ||||
| FieldableEntityDefinitionUpdateTest::assertRevisionable | protected | function | Asserts the revisionable characteristics of an entity type. | ||||
| FieldableEntityDefinitionUpdateTest::assertRevisionableAndTranslatable | protected | function | Asserts the revisionable / translatable characteristics of an entity type. | ||||
| FieldableEntityDefinitionUpdateTest::assertTranslatable | protected | function | Asserts the translatable characteristics of an entity type. | ||||
| FieldableEntityDefinitionUpdateTest::insertData | protected | function | Generates test entities for the 'entity_test_update' entity type. | ||||
| FieldableEntityDefinitionUpdateTest::setUp | protected | function | Overrides EntityKernelTestBase::setUp | ||||
| FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesErrorHandling | public | function | Tests that a failed entity schema update preserves the existing data. | ||||
| FieldableEntityDefinitionUpdateTest::testFieldableEntityTypeUpdatesRemoveBackupTables | public | function | Tests the removal of the backup tables after a successful update. | ||||
| KernelTestBase::$backupGlobals | protected | property | Back up and restore any global variables that may be changed by tests. | ||||
| KernelTestBase::$backupStaticAttributes | protected | property | Back up and restore static class properties that may be changed by tests. | ||||
| KernelTestBase::$backupStaticAttributesBlacklist | protected | property | Contains a few static class properties for performance. | ||||
| KernelTestBase::$classLoader | protected | property | |||||
| KernelTestBase::$configImporter | protected | property | @todo Move into Config test base class. | 6 | |||
| KernelTestBase::$configSchemaCheckerExclusions | protected static | property | An array of config object names that are excluded from schema checking. | 3 | |||
| KernelTestBase::$container | protected | property | |||||
| KernelTestBase::$databasePrefix | protected | property | |||||
| KernelTestBase::$keyValue | protected | property | The key_value service that must persist between container rebuilds. | ||||
| KernelTestBase::$preserveGlobalState | protected | property | Do not forward any global state from the parent process to the processes that run the actual tests.  | 
                                                                                        ||||
| KernelTestBase::$root | protected | property | The app root. | ||||
| KernelTestBase::$runTestInSeparateProcess | protected | property | Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property.  | 
                                                                                        ||||
| KernelTestBase::$siteDirectory | protected | property | |||||
| KernelTestBase::$strictConfigSchema | protected | property | Set to TRUE to strict check all configuration saved. | 9 | |||
| KernelTestBase::$usesSuperUserAccessPolicy | protected | property | Set to TRUE to make user 1 a super user. | 7 | |||
| KernelTestBase::$vfsRoot | protected | property | The virtual filesystem root directory. | ||||
| KernelTestBase::assertPostConditions | protected | function | 1 | ||||
| KernelTestBase::bootEnvironment | protected | function | Bootstraps a basic test environment. | ||||
| KernelTestBase::bootKernel | protected | function | Bootstraps a kernel for a test. | 1 | |||
| KernelTestBase::config | protected | function | Configuration accessor for tests. Returns non-overridden configuration. | ||||
| KernelTestBase::disableModules | protected | function | Disables modules for this test. | ||||
| KernelTestBase::enableModules | protected | function | Enables modules for this test. | 1 | |||
| KernelTestBase::getConfigSchemaExclusions | protected | function | Gets the config schema exclusions for this test. | ||||
| KernelTestBase::getDatabaseConnectionInfo | protected | function | Returns the Database connection info to be used for this test. | 2 | |||
| KernelTestBase::getDatabasePrefix | public | function | |||||
| KernelTestBase::getExtensionsForModules | private | function | Returns Extension objects for $modules to install. | ||||
| KernelTestBase::getModulesToEnable | private static | function | Returns the modules to install for this test. | ||||
| KernelTestBase::initFileCache | protected | function | Initializes the FileCache component. | ||||
| KernelTestBase::installConfig | protected | function | Installs default configuration for a given list of modules. | ||||
| KernelTestBase::installEntitySchema | protected | function | Installs the storage schema for a specific entity type. | ||||
| KernelTestBase::installSchema | protected | function | Installs database tables from a module schema definition. | ||||
| KernelTestBase::register | public | function | Registers test-specific services. | Overrides ServiceProviderInterface::register | 27 | ||
| KernelTestBase::render | protected | function | Renders a render array. | 1 | |||
| KernelTestBase::setInstallProfile | protected | function | Sets the install profile and rebuilds the container to update it. | ||||
| KernelTestBase::setSetting | protected | function | Sets an in-memory Settings variable. | ||||
| KernelTestBase::setUpBeforeClass | public static | function | 1 | ||||
| KernelTestBase::setUpFilesystem | protected | function | Sets up the filesystem, so things like the file directory. | 2 | |||
| KernelTestBase::stop | Deprecated | protected | function | Stops test execution. | |||
| KernelTestBase::tearDown | protected | function | 6 | ||||
| KernelTestBase::tearDownCloseDatabaseConnection | public | function | @after | ||||
| KernelTestBase::vfsDump | protected | function | Dumps the current state of the virtual filesystem to STDOUT. | ||||
| KernelTestBase::__get | public | function | |||||
| KernelTestBase::__sleep | public | function | Prevents serializing any properties. | ||||
| PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | ||||
| PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | ||||
| RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | ||||
| RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | ||||
| RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | ||||
| RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | ||||
| RandomGeneratorTrait::randomStringValidate | Deprecated | public | function | Callback for random string validation. | |||
| StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. | ||||
| TestRequirementsTrait::checkModuleRequirements | Deprecated | private | function | Checks missing module requirements. | |||
| TestRequirementsTrait::checkRequirements | Deprecated | protected | function | Check module requirements for the Drupal use case. | |||
| TestRequirementsTrait::getDrupalRoot | protected static | function | Returns the Drupal root directory. | ||||
| UserCreationTrait::checkPermissions | protected | function | Checks whether a given list of permission names is valid. | Aliased as: drupalCheckPermissions | |||
| UserCreationTrait::createAdminRole | protected | function | Creates an administrative role. | Aliased as: drupalCreateAdminRole | |||
| UserCreationTrait::createRole | protected | function | Creates a role with specified permissions. | Aliased as: drupalCreateRole | |||
| UserCreationTrait::createUser | protected | function | Create a user with a given set of permissions. | Aliased as: drupalCreateUser | |||
| UserCreationTrait::grantPermissions | protected | function | Grant permissions to a user role. | Aliased as: drupalGrantPermissions | |||
| UserCreationTrait::setCurrentUser | protected | function | Switch the current logged in user. | Aliased as: drupalSetCurrentUser | |||
| UserCreationTrait::setUpCurrentUser | protected | function | Creates a random user account and sets it as current user. | Aliased as: drupalSetUpCurrentUser | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.