You are here

protected function MigrateUiParagraphsTestBase::assertParagraphsMigrationResults in Paragraphs 8

Checks that migrations have been performed successfully.

1 call to MigrateUiParagraphsTestBase::assertParagraphsMigrationResults()
MigrateUiParagraphsTest::testParagraphsMigrate in tests/src/Functional/Migrate/MigrateUiParagraphsTest.php
Tests the result of the paragraphs migration.

File

tests/src/Functional/Migrate/MigrateUiParagraphsTestBase.php, line 452

Class

MigrateUiParagraphsTestBase
Provides a base class for testing Paragraphs migration via the UI.

Namespace

Drupal\Tests\paragraphs\Functional\Migrate

Code

protected function assertParagraphsMigrationResults() {
  $version = $this
    ->getLegacyDrupalVersion($this->sourceDatabase);
  $this
    ->assertEntities();
  $plugin_manager = $this->container
    ->get('plugin.manager.migration');

  /** @var \Drupal\migrate\Plugin\Migration[] $all_migrations */
  $all_migrations = $plugin_manager
    ->createInstancesByTag('Drupal ' . $version);
  foreach ($all_migrations as $migration) {
    $id_map = $migration
      ->getIdMap();
    foreach ($id_map as $source_id => $map) {

      // Convert $source_id into a keyless array so that
      // \Drupal\migrate\Plugin\migrate\id_map\Sql::getSourceHash() works as
      // expected.
      $source_id_values = array_values(unserialize($source_id));
      $row = $id_map
        ->getRowBySource($source_id_values);
      $destination = serialize($id_map
        ->currentDestination());
      $message = "Migration of {$source_id} to {$destination} as part of the {$migration->id()} migration. The source row status is " . $row['source_row_status'];

      // A completed migration should have maps with
      // MigrateIdMapInterface::STATUS_IGNORED or
      // MigrateIdMapInterface::STATUS_IMPORTED.
      $this
        ->assertNotSame(MigrateIdMapInterface::STATUS_FAILED, $row['source_row_status'], $message);
      $this
        ->assertNotSame(MigrateIdMapInterface::STATUS_NEEDS_UPDATE, $row['source_row_status'], $message);
    }
  }
}