function MigrateDrupal6AuditIdsTest::testDraftRevisionIdConflicts

Same name in other branches
  1. 8.9.x core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6AuditIdsTest::testDraftRevisionIdConflicts()
  2. 10 core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6AuditIdsTest::testDraftRevisionIdConflicts()
  3. 11.x core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6AuditIdsTest::testDraftRevisionIdConflicts()

Tests draft revisions ID conflicts.

File

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

Class

MigrateDrupal6AuditIdsTest
Tests the migration auditor for ID conflicts.

Namespace

Drupal\Tests\migrate_drupal\Kernel\d6

Code

public function testDraftRevisionIdConflicts() {
    // Create a published node of type page.
    $node = Node::create([
        'type' => 'page',
        'title' => 'foo',
    ]);
    $node->moderation_state->value = 'published';
    $node->save();
    // Create a draft revision.
    $node->moderation_state->value = 'draft';
    $node->setNewRevision(TRUE);
    $node->save();
    // Insert data in the d6_node_revision:page migration mapping table to
    // simulate a previously migrated node revision.
    $id_map = $this->getMigration('d6_node_revision: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 d6_node_revision migration. There should be
    // conflicts since a draft revision has been created.
    
    /** @var \Drupal\migrate\Audit\AuditResult $result */
    $result = (new IdAuditor())->audit($this->getMigration('d6_node_revision:page'));
    $this->assertInstanceOf(AuditResult::class, $result);
    $this->assertFalse($result->passed());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.