You are here

public function MigrateDrupal6AuditIdsTest::testAllMigrationsWithIdConflicts in Drupal 10

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

Tests all migrations with ID conflicts.

File

core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php, line 113

Class

MigrateDrupal6AuditIdsTest
Tests the migration auditor for ID conflicts.

Namespace

Drupal\Tests\migrate_drupal\Kernel\d6

Code

public function testAllMigrationsWithIdConflicts() {

  // Get all Drupal 6 migrations.
  $migrations = $this->container
    ->get('plugin.manager.migration')
    ->createInstancesByTag('Drupal 6');

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

  // Audit the IDs of all 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 = [
    'd6_comment',
    'd6_custom_block',
    'd6_file',
    'd6_menu_links',
    'd6_node',
    'd6_node_complete',
    'd6_node_revision',
    'd6_taxonomy_term',
    'd6_term_node_revision',
    'd6_user',
    'node_translation_menu_links',
  ];
  $this
    ->assertEmpty(array_diff(array_filter($conflicts), $expected));
}