You are here

public function MigrateInterruptionTest::testMigrateEvents in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/Tests/MigrateInterruptionTest.php \Drupal\migrate\Tests\MigrateInterruptionTest::testMigrateEvents()

Tests migration interruptions.

File

core/modules/migrate/src/Tests/MigrateInterruptionTest.php, line 44
Contains \Drupal\migrate\Tests\MigrateInterruptionTest.

Class

MigrateInterruptionTest
Tests interruptions triggered during migrations.

Namespace

Drupal\migrate\Tests

Code

public function testMigrateEvents() {

  // Run a simple little migration, which should trigger one of each event
  // other than map_delete.
  $config = [
    'id' => 'sample_data',
    '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 = Migration::create($config);

  /** @var MigrationInterface $migration */
  $executable = new MigrateExecutable($migration, new MigrateMessage());

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

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