public function EntityDefinitionUpdateTest::testEntityIndexCreateWithData in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testEntityIndexCreateWithData()
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\EntityDefinitionUpdateTest::testEntityIndexCreateWithData()
Tests creating a multi-field index when there are existing entities.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityDefinitionUpdateTest.php, line 914
Class
- EntityDefinitionUpdateTest
- Tests EntityDefinitionUpdateManager functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testEntityIndexCreateWithData() {
// Save an entity.
$name = $this
->randomString();
$entity = $this->entityTypeManager
->getStorage('entity_test_update')
->create([
'name' => $name,
]);
$entity
->save();
// Add an entity index, run the update. Ensure that the index is created
// despite having data.
$this
->addEntityIndex();
$entity_type = \Drupal::entityTypeManager()
->getDefinition('entity_test_update');
$original = \Drupal::service('entity.last_installed_schema.repository')
->getLastInstalledDefinition('entity_test_update');
\Drupal::service('entity_type.listener')
->onEntityTypeUpdate($entity_type, $original);
$this
->assertTrue($this->database
->schema()
->indexExists('entity_test_update', 'entity_test_update__new_index'), 'Index added.');
}