X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmigrate%2Ftests%2Fsrc%2FKernel%2FPlugin%2FMigrationTest.php;fp=web%2Fcore%2Fmodules%2Fmigrate%2Ftests%2Fsrc%2FKernel%2FPlugin%2FMigrationTest.php;h=a8dddd277ac9929353d018127ac503eb8dbf82cc;hp=c2cec4cff6e342d46761dcfc997f483a4b6d63ae;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php b/web/core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php index c2cec4cff..a8dddd277 100644 --- a/web/core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php +++ b/web/core/modules/migrate/tests/src/Kernel/Plugin/MigrationTest.php @@ -3,6 +3,8 @@ namespace Drupal\Tests\migrate\Kernel\Plugin; use Drupal\KernelTests\KernelTestBase; +use Drupal\migrate\MigrateException; +use Drupal\migrate\MigrateSkipRowException; /** * Tests the migration plugin. @@ -27,6 +29,17 @@ class MigrationTest extends KernelTestBase { $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() * @@ -39,7 +52,7 @@ class MigrationTest extends KernelTestBase { 'f1' => 'bar', 'f2' => [ 'plugin' => 'migration', - 'migration' => 'm1' + 'migration' => 'm1', ], 'f3' => [ 'plugin' => 'sub_process', @@ -50,10 +63,32 @@ class MigrationTest extends KernelTestBase { ], ], ], + '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()); } /** @@ -81,4 +116,15 @@ class MigrationTest extends KernelTestBase { $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); + } + }