diff -u b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php --- b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php +++ b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php @@ -88,8 +88,7 @@ public function supportsRollback(); /** - * After import() is called, the appropriate rollback action for the last - * imported item. + * The rollback action for the last imported item. * * @return int * The MigrateIdMapInterface::ROLLBACK_ constant indicating how an imported diff -u b/core/modules/migrate/src/Tests/MigrateRollbackTest.php b/core/modules/migrate/src/Tests/MigrateRollbackTest.php --- b/core/modules/migrate/src/Tests/MigrateRollbackTest.php +++ b/core/modules/migrate/src/Tests/MigrateRollbackTest.php @@ -112,13 +112,20 @@ $this->assertTrue($term_migration->getDestinationPlugin()->supportsRollback()); // Pre-create a term, to make sure it isn't deleted on rollback. - $preserved_term_id = 1; - $new_term = Term::create(['tid' => $preserved_term_id, 'vid' => 1, 'name' => 'music']); + $preserved_term_ids[] = 1; + $new_term = Term::create(['tid' => 1, 'vid' => 1, 'name' => 'music']); $new_term->save(); // Import and validate term entities were created. $term_executable = new MigrateExecutable($term_migration, $this); $term_executable->import(); + // Also explicitly mark one row to be preserved on rollback. + $preserved_term_ids[] = 2; + $map_row = $term_id_map->getRowBySource(['id' => 2]); + $dummy_row = new Row(['id' => 2], $ids); + $term_id_map->saveIdMapping($dummy_row, [$map_row['destid1']], + $map_row['source_row_status'], MigrateIdMapInterface::ROLLBACK_PRESERVE); + foreach ($term_data_rows as $row) { /** @var Term $term */ $term = Term::load($row['id']); @@ -131,7 +138,7 @@ $term_executable->rollback(); foreach ($term_data_rows as $row) { $term = Term::load($row['id']); - if ($row['id'] == $preserved_term_id) { + if (in_array($row['id'], $preserved_term_ids)) { $this->assertNotNull($term); } else { diff -u b/core/modules/user/src/Tests/Migrate/d6/MigrateUserTest.php b/core/modules/user/src/Tests/Migrate/d6/MigrateUserTest.php --- b/core/modules/user/src/Tests/Migrate/d6/MigrateUserTest.php +++ b/core/modules/user/src/Tests/Migrate/d6/MigrateUserTest.php @@ -133,9 +133,7 @@ foreach ($users as $uid) { $account = User::load($uid); if ($uid == 1) { - // assertNotNull()'s call to var_export() is unhappy with recursiveness - // of the account object. - $this->assertFalse(is_null($account)); + $this->assertNotNull($account, 'User 1 was preserved after rollback'); } else { $this->assertNull($account);