namespace Drupal\Tests\migrate\Kernel\Plugin;
use Drupal\KernelTests\KernelTestBase;
+use Drupal\migrate\MigrateException;
+use Drupal\migrate\MigrateSkipRowException;
/**
* Tests the migration plugin.
$this->assertEquals([], $migration->getProcessPlugins([]));
}
+ /**
+ * Tests Migration::getProcessPlugins() throws an exception.
+ *
+ * @covers ::getProcessPlugins
+ */
+ public function testGetProcessPluginsException() {
+ $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
+ $this->setExpectedException(MigrateException::class, 'Invalid process configuration for foobar');
+ $migration->getProcessPlugins(['foobar' => ['plugin' => 'get']]);
+ }
+
/**
* Tests Migration::getMigrationDependencies()
*
'f1' => 'bar',
'f2' => [
'plugin' => 'migration',
- 'migration' => 'm1'
+ 'migration' => 'm1',
],
'f3' => [
'plugin' => 'sub_process',
],
],
],
+ 'f4' => [
+ 'plugin' => 'migration_lookup',
+ 'migration' => 'm3',
+ ],
+ 'f5' => [
+ 'plugin' => 'sub_process',
+ 'process' => [
+ 'target_id' => [
+ 'plugin' => 'migration_lookup',
+ 'migration' => 'm4',
+ ],
+ ],
+ ],
+ 'f6' => [
+ 'plugin' => 'iterator',
+ 'process' => [
+ 'target_id' => [
+ 'plugin' => 'migration_lookup',
+ 'migration' => 'm5',
+ ],
+ ],
+ ],
],
];
$migration = $plugin_manager->createStubMigration($plugin_definition);
- $this->assertSame(['required' => [], 'optional' => ['m1', 'm2']], $migration->getMigrationDependencies());
+ $this->assertSame(['required' => [], 'optional' => ['m1', 'm2', 'm3', 'm4', 'm5']], $migration->getMigrationDependencies());
}
/**
$this->assertEquals(TRUE, $migration->isTrackLastImported());
}
+ /**
+ * Tests Migration::getDestinationPlugin()
+ *
+ * @covers ::getDestinationPlugin
+ */
+ public function testGetDestinationPlugin() {
+ $migration = \Drupal::service('plugin.manager.migration')->createStubMigration(['destination' => ['no_stub' => TRUE]]);
+ $this->setExpectedException(MigrateSkipRowException::class, "Stub requested but not made because no_stub configuration is set.");
+ $migration->getDestinationPlugin(TRUE);
+ }
+
}