protected function MigrateUpgradeEckTest::assertUpgrade in Entity Construction Kit (ECK) 8
Asserts the upgrade completed successfully.
Parameters
array $entity_counts: An array of entity count, where the key is the entity type and the value is the number of the entities that should exist post migration.
1 call to MigrateUpgradeEckTest::assertUpgrade()
- MigrateUpgradeEckTest::testMigrateUpgrade in tests/
src/ Functional/ MigrateUpgradeEckTest.php - Tests the migrate upgrade review form and upgrade process.
File
- tests/
src/ Functional/ MigrateUpgradeEckTest.php, line 128
Class
- MigrateUpgradeEckTest
- Tests ECK upgrade using the migrate UI.
Namespace
Drupal\Tests\eck\FunctionalCode
protected function assertUpgrade(array $entity_counts) {
// Assert the count of entities after the upgrade. First, reset all the
// statics after migration to ensure entities are loadable.
$this
->resetAll();
// Check that the expected number of entities is the same as the actual
// number of entities.
$entity_definitions = array_keys(\Drupal::entityTypeManager()
->getDefinitions());
// Ignore some entity types because the counts are different in different
// core versions.
$ignored_entity_types = [
'tour',
'image_style',
];
$entity_definitions = array_diff($entity_definitions, $ignored_entity_types);
ksort($entity_counts);
$expected_count_keys = array_keys($entity_counts);
sort($entity_definitions);
$this
->assertSame($expected_count_keys, $entity_definitions);
// Assert the correct number of entities exists.
$actual_entity_counts = [];
foreach ($entity_definitions as $entity_type) {
$actual_entity_counts[$entity_type] = (int) \Drupal::entityQuery($entity_type)
->accessCheck(FALSE)
->count()
->execute();
}
$this
->assertSame($entity_counts, $actual_entity_counts);
}