public function MigrateSkipRowTest::testPrepareRowSkip in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/migrate/src/Tests/MigrateSkipRowTest.php \Drupal\migrate\Tests\MigrateSkipRowTest::testPrepareRowSkip()
Tests migration interruptions.
File
- core/
modules/ migrate/ src/ Tests/ MigrateSkipRowTest.php, line 34 - Contains \Drupal\migrate\Tests\MigrateSkipRowTest.
Class
- MigrateSkipRowTest
- Tests row skips triggered during hook_migrate_prepare_row().
Namespace
Drupal\migrate\TestsCode
public function testPrepareRowSkip() {
// Run a simple little migration with two data rows which should be skipped
// in different ways.
$config = [
'id' => 'sample_data',
'migration_tags' => [
'prepare_row test',
],
'source' => [
'plugin' => 'embedded_data',
'data_rows' => [
[
'id' => '1',
'data' => 'skip_and_record',
],
[
'id' => '2',
'data' => 'skip_and_dont_record',
],
],
'ids' => [
'id' => [
'type' => 'string',
],
],
],
'process' => [
'value' => 'data',
],
'destination' => [
'plugin' => 'config',
'config_name' => 'migrate_test.settings',
],
'load' => [
'plugin' => 'null',
],
];
$migration = Migration::create($config);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$result = $executable
->import();
$this
->assertEqual($result, MigrationInterface::RESULT_COMPLETED);
$id_map_plugin = $migration
->getIdMap();
// The first row is recorded in the map as ignored.
$map_row = $id_map_plugin
->getRowBySource([
'id' => 1,
]);
$this
->assertEqual(MigrateIdMapInterface::STATUS_IGNORED, $map_row['source_row_status']);
// The second row is not recorded in the map.
$map_row = $id_map_plugin
->getRowBySource([
'id' => 2,
]);
$this
->assertFalse($map_row);
}