You are here

public function MigrateTableTest::testTableUpdate in Migrate Plus 8.5

Tests table update.

@dataProvider tableDestinationMigration

File

tests/src/Kernel/MigrateTableTest.php, line 217

Class

MigrateTableTest
Tests migration destination table.

Namespace

Drupal\Tests\migrate_plus\Kernel

Code

public function testTableUpdate(array $definition) : void {

  // Make sure migration overwrites the original data for the first row.
  $original_values = [
    'data' => 'dummy value',
    'data2' => 'original value 2',
    'data3' => 'original value 3',
  ];
  $this->connection
    ->insert(static::DEST_TABLE_NAME)
    ->fields($original_values)
    ->execute();

  /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
  $migration = \Drupal::service('plugin.manager.migration')
    ->createStubMigration($definition);
  $migration
    ->getIdMap()
    ->saveIdMapping(new Row($original_values, [
    'data' => 'dummy value',
  ]), [
    'data' => 'dummy value',
  ], MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
  $this
    ->testTableMigration();
}