function MigrateDrupal7AuditIdsTest::testDraftRevisionIdConflicts

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

Tests draft revisions ID conflicts.

File

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

Class

MigrateDrupal7AuditIdsTest
Tests the migration auditor for ID conflicts.

Namespace

Drupal\Tests\migrate_drupal\Kernel\d7

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 d7_node_revision:page migration mapping table to
    // simulate a previously migrated node revision.
    $id_map = $this->getMigration('d7_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 d7_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('d7_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.