You are here

public function MigrateInterruptionTest::testMigrateEvents in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php \Drupal\Tests\migrate\Kernel\MigrateInterruptionTest::testMigrateEvents()
  2. 9 core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php \Drupal\Tests\migrate\Kernel\MigrateInterruptionTest::testMigrateEvents()

Tests migration interruptions.

File

core/modules/migrate/tests/src/Kernel/MigrateInterruptionTest.php, line 37

Class

MigrateInterruptionTest
Tests interruptions triggered during migrations.

Namespace

Drupal\Tests\migrate\Kernel

Code

public function testMigrateEvents() {

  // Run a simple little migration, which should trigger one of each event
  // other than map_delete.
  $definition = [
    'migration_tags' => [
      'Interruption test',
    ],
    'source' => [
      'plugin' => 'embedded_data',
      'data_rows' => [
        [
          'data' => 'dummy value',
        ],
        [
          'data' => 'dummy value2',
        ],
      ],
      'ids' => [
        'data' => [
          'type' => 'string',
        ],
      ],
    ],
    'process' => [
      'value' => 'data',
    ],
    'destination' => [
      'plugin' => 'dummy',
    ],
  ];
  $migration = \Drupal::service('plugin.manager.migration')
    ->createStubMigration($definition);
  $executable = new MigrateExecutable($migration);

  // When the import runs, the first row imported will trigger an
  // interruption.
  $result = $executable
    ->import();
  $this
    ->assertEquals(MigrationInterface::RESULT_INCOMPLETE, $result);

  // The status should have been reset to IDLE.
  $this
    ->assertEquals(MigrationInterface::STATUS_IDLE, $migration
    ->getStatus());
}