function EntityDefinitionUpdateTest::testEntityTypeUpdateWithoutData
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testEntityTypeUpdateWithoutData()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testEntityTypeUpdateWithoutData()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testEntityTypeUpdateWithoutData()
Tests updating entity schema when there are no existing entities.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityDefinitionUpdateTest.php, line 110
Class
- EntityDefinitionUpdateTest
- Tests EntityDefinitionUpdateManager functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testEntityTypeUpdateWithoutData() : void {
// The 'entity_test_update' entity type starts out non-revisionable, so
// ensure the revision table hasn't been created during setUp().
$this->assertFalse($this->database
->schema()
->tableExists('entity_test_update_revision'), 'Revision table not created for entity_test_update.');
// Update it to be revisionable and ensure the definition update manager
// reports that an update is needed.
$this->updateEntityTypeToRevisionable();
$this->assertTrue($this->entityDefinitionUpdateManager
->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.');
$expected = [
'entity_test_update' => [
t('The %entity_type entity type needs to be updated.', [
'%entity_type' => $this->entityTypeManager
->getDefinition('entity_test_update')
->getLabel(),
]),
// The revision key is now defined, so the revision field needs to be
// created.
t('The %field_name field needs to be installed.', [
'%field_name' => 'Revision ID',
]),
t('The %field_name field needs to be installed.', [
'%field_name' => 'Default revision',
]),
],
];
$this->assertEquals($expected, $this->entityDefinitionUpdateManager
->getChangeSummary(), 'EntityDefinitionUpdateManager reports the expected change summary.');
// Run the update and ensure the revision table is created.
$this->updateEntityTypeToRevisionable(TRUE);
$this->assertTrue($this->database
->schema()
->tableExists('entity_test_update_revision'), 'Revision table created for entity_test_update.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.