Asserts that the expected entities exist.
protected function assertEntities() {
foreach ($this
->getExpectedEntities() as $entity_type_id => $expected_entity_labels) {
if ($storage = $this
->getEntityStorage($entity_type_id)) {
$entities = $storage
->loadMultiple();
$actual_labels = array_reduce($entities, function ($carry, EntityInterface $entity) {
$carry[$entity
->id()] = (string) $entity
->label();
return $carry;
});
if (\Drupal::database()
->driver() === 'pgsql') {
// On PostgreSQL the entity IDs are not the same so only compare the
// labels to ensure we've migrated the expected number of entities.
$this
->assertEqualsCanonicalizing($expected_entity_labels, $actual_labels, sprintf('The expected %s entities are not matching the actual ones.', $entity_type_id));
}
else {
$this
->assertEquals($expected_entity_labels, $actual_labels, sprintf('The expected %s entities are not matching the actual ones.', $entity_type_id));
}
}
else {
$this
->fail(sprintf('The expected %s entity type is missing.', $entity_type_id));
}
}
}