protected function FieldableEntityDefinitionUpdateTest::assertRevisionableAndTranslatable in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertRevisionableAndTranslatable()
- 9 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertRevisionableAndTranslatable()
Asserts the revisionable / translatable characteristics of an entity type.
@internal
1 call to FieldableEntityDefinitionUpdateTest::assertRevisionableAndTranslatable()
- FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ FieldableEntityDefinitionUpdateTest.php - Asserts revisionable and/or translatable characteristics of an entity type.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ FieldableEntityDefinitionUpdateTest.php, line 567
Class
- FieldableEntityDefinitionUpdateTest
- Tests EntityDefinitionUpdateManager's fieldable entity update functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
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));
}
}
}