You are here

public function MigrateDrupal7AuditIdsTest::testAllMigrationsWithIdConflicts in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7AuditIdsTest::testAllMigrationsWithIdConflicts()
  2. 9 core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7AuditIdsTest::testAllMigrationsWithIdConflicts()

Tests all migrations with ID conflicts.

File

core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php, line 113

Class

MigrateDrupal7AuditIdsTest
Tests the migration auditor for ID conflicts.

Namespace

Drupal\Tests\migrate_drupal\Kernel\d7

Code

public function testAllMigrationsWithIdConflicts() {
  $migrations = $this->container
    ->get('plugin.manager.migration')
    ->createInstancesByTag('Drupal 7');

  // Create content.
  $this
    ->createContent();

  // Audit the IDs of all Drupal 7 migrations. There should be conflicts since
  // content has been created.
  $conflicts = array_map(function (AuditResult $result) {
    return $result
      ->passed() ? NULL : $result
      ->getMigration()
      ->getBaseId();
  }, (new IdAuditor())
    ->auditMultiple($migrations));
  $expected = [
    'd7_comment',
    'd7_custom_block',
    'd7_file',
    'd7_file_private',
    'd7_menu_links',
    'd7_node',
    'd7_node_complete',
    'd7_node_revision',
    'd7_taxonomy_term',
    'd7_user',
    'node_translation_menu_links',
  ];
  $this
    ->assertEmpty(array_diff(array_filter($conflicts), $expected));
}