function MigrateDrupal7AuditIdsTest::testMultipleMigrationWithoutIdConflicts
Same name in other branches
- 8.9.x core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7AuditIdsTest::testMultipleMigrationWithoutIdConflicts()
- 10 core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7AuditIdsTest::testMultipleMigrationWithoutIdConflicts()
- 11.x core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7AuditIdsTest::testMultipleMigrationWithoutIdConflicts()
Tests multiple migrations to the same destination with no ID conflicts.
File
-
core/
modules/ migrate_drupal/ tests/ src/ Kernel/ d7/ MigrateDrupal7AuditIdsTest.php, line 57
Class
- MigrateDrupal7AuditIdsTest
- Tests the migration auditor for ID conflicts.
Namespace
Drupal\Tests\migrate_drupal\Kernel\d7Code
public function testMultipleMigrationWithoutIdConflicts() {
// Create a node of type page.
$node = Node::create([
'type' => 'page',
'title' => 'foo',
]);
$node->moderation_state->value = 'published';
$node->save();
// Insert data in the d7_node:page migration mapping table to simulate a
// previously migrated node.
$id_map = $this->getMigration('d7_node:page')
->getIdMap();
$table_name = $id_map->mapTableName();
$id_map->getDatabase()
->insert($table_name)
->fields([
'source_ids_hash' => 1,
'sourceid1' => 1,
'destid1' => 1,
])
->execute();
// Audit the IDs of the d7_node migrations for the page & article node type.
// There should be no conflicts since the highest destination ID should be
// equal to the highest migrated ID, as found in the aggregated mapping
// tables of the two node migrations.
$migrations = [
$this->getMigration('d7_node:page'),
$this->getMigration('d7_node:article'),
];
$results = (new IdAuditor())->auditMultiple($migrations);
/** @var \Drupal\migrate\Audit\AuditResult $result */
foreach ($results as $result) {
$this->assertInstanceOf(AuditResult::class, $result);
$this->assertTrue($result->passed());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.