Commit 95b3b178 authored by catch's avatar catch

Issue #3023747 by mikelutz, heddn: D6 profile migrations assume stubs, which fail

parent 34b94c8c
<?php
namespace Drupal\Tests\migrate_drupal\Kernel\d6;
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
/**
* Tests the getProcess() method of all Drupal 6 migrations.
*
* @group migrate_drupal
*/
class MigrationProcessTest extends MigrateDrupal6TestBase {
use FileSystemModuleDiscoveryDataProviderTrait;
/**
* {@inheritdoc}
*/
public function setUp() {
self::$modules = array_keys($this->coreModuleListDataProvider());
parent::setUp();
}
/**
* Tests that calling getProcess() on a migration does not throw an exception.
*
* @throws \Exception
*/
public function testGetProcess() {
/** @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager */
$plugin_manager = $this->container->get('plugin.manager.migration');
$migrations = $plugin_manager->createInstancesByTag('Drupal 6');
foreach ($migrations as $migration) {
try {
$process = $migration->getProcess();
}
catch (\Exception $e) {
$this->fail(sprintf("Migration %s process failed with error: %s", $migration->label(), $e->getMessage()));
}
$this->assertNotNull($process);
}
}
}
<?php
namespace Drupal\Tests\migrate_drupal\Kernel\d7;
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
/**
* Tests the getProcess() method of all Drupal 7 migrations.
*
* @group migrate_drupal
*/
class MigrationProcessTest extends MigrateDrupal7TestBase {
use FileSystemModuleDiscoveryDataProviderTrait;
/**
* {@inheritdoc}
*/
public function setUp() {
self::$modules = array_keys($this->coreModuleListDataProvider());
parent::setUp();
}
/**
* Tests that calling getProcess() on a migration does not throw an exception.
*
* @throws \Exception
*/
public function testGetProcess() {
/** @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager */
$plugin_manager = $this->container->get('plugin.manager.migration');
$migrations = $plugin_manager->createInstancesByTag('Drupal 7');
foreach ($migrations as $migration) {
try {
$process = $migration->getProcess();
}
catch (\Exception $e) {
$this->fail(sprintf("Migration %s process failed with error: %s", $migration->label(), $e->getMessage()));
}
$this->assertNotNull($process);
}
}
}
......@@ -4,7 +4,6 @@
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\Migration;
/**
......@@ -32,6 +31,7 @@ public function getProcess() {
$definition['destination']['plugin'] = 'null';
$definition['idMap']['plugin'] = 'null';
try {
$this->checkRequirements();
$profile_field_migration = $this->migrationPluginManager->createStubMigration($definition);
$migrate_executable = new MigrateExecutable($profile_field_migration);
$source_plugin = $profile_field_migration->getSourcePlugin();
......@@ -45,6 +45,7 @@ public function getProcess() {
[
'migration' => 'user_profile_field',
'source_ids' => $fid,
'no_stub' => TRUE,
];
$plugin = $this->processPluginManager->createInstance('migration_lookup', $configuration, $profile_field_migration);
$new_value = $plugin->transform($fid, $migrate_executable, $row, 'tmp');
......@@ -52,14 +53,12 @@ public function getProcess() {
// Set the destination to the migrated profile field name.
$this->process[$new_value[1]] = $name;
}
else {
throw new MigrateSkipRowException("Can't migrate source field $name.");
}
}
}
catch (RequirementsException $e) {
// The checkRequirements() call will fail when the profile module does
// not exist on the source site.
// not exist on the source site, or if the required migrations have not
// yet run.
}
}
return parent::getProcess();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment