Commit 4cc0d6d4 authored by webchick's avatar webchick

Issue #2560671 by phenaproxima, neclimdul: The Migration process plugin should not skip rows

parent 7f3d4132
......@@ -20,13 +20,13 @@ process:
migration: d6_field
source:
- field_name
-
plugin: skip_on_empty
method: row
-
plugin: extract
index:
- 1
-
plugin: skip_on_empty
method: row
entity_type: 'constants/entity_type'
bundle: type_name
view_mode:
......@@ -35,6 +35,9 @@ process:
migration: d6_view_modes
source:
- view_mode
-
plugin: skip_on_empty
method: row
-
plugin: extract
index:
......
......@@ -11,7 +11,6 @@
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateSkipProcessException;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Entity\MigrationInterface;
......@@ -145,7 +144,6 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
return $destination_ids;
}
}
throw new MigrateSkipRowException();
}
/**
......
<?php
/**
* @file
* Contains \Drupal\Tests\migrate\Unit\process\MigrationTest.
*/
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\migrate\process\Migration;
/**
* Tests the migration process plugin.
*
* @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\Migration
* @group migrate
*/
class MigrationTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->migrationConfiguration = [
'id' => 'test',
'process' => [],
'source' => [],
];
parent::setUp();
}
/**
* Assert that exceptions during import are logged.
* @expectedException \Drupal\migrate\MigrateSkipRowException
* @covers ::transform
*/
public function testSaveOnException() {
// A bunch of mock objects to get thing working
$migration = $this->getMigration();
$migration_source = $this->getMock('\Drupal\migrate\Plugin\MigrateSourceInterface');
$migration_source->expects($this->once())
->method('getIds')
->willReturn([]);
$migration->expects($this->once())
->method('getSourcePlugin')
->willReturn($migration_source);
$migration_destination = $this->getMock('\Drupal\migrate\Plugin\MigrateDestinationInterface');
$migration->expects($this->once())
->method('getDestinationPlugin')
->willReturn($migration_destination);
$storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('loadMultiple')
->willReturn([
'id' => $migration
]);
$manager = $this->getMockBuilder('\Drupal\migrate\Plugin\MigratePluginManager')
->disableOriginalConstructor()
->getMock();
// Throw an exception during import so we can log it.
$migration_destination->expects($this->once())
->method('import')
->willThrowException(new MigrateException());
// Build our migration plugin.
$plugin = new Migration(['migration' => []],
'migration', // ?
[],
$migration,
$storage,
$manager);
// Assert that we log exceptions thrown during the import.
$this->migrateExecutable->expects($this->once())
->method('saveMessage');
$plugin->transform('value', $this->migrateExecutable, $this->row, 'prop');
}
}
......@@ -13,9 +13,13 @@ process:
entity_type: 'constants/entity_type'
type: 'constants/type'
field_name:
plugin: migration
migration: d6_taxonomy_vocabulary
source: vid
-
plugin: migration
migration: d6_taxonomy_vocabulary
source: vid
-
plugin: skip_on_empty
method: row
'settings/target_type': 'constants/target_entity_type'
cardinality: 'constants/cardinality'
destination:
......
......@@ -12,9 +12,13 @@ process:
entity_type: 'constants/entity_type'
bundle: type
field_name:
plugin: migration
migration: d6_taxonomy_vocabulary
source: vid
-
plugin: migration
migration: d6_taxonomy_vocabulary
source: vid
-
plugin: skip_on_empty
method: row
'settings/handler': 'constants/selection_handler'
'settings/handler_settings/target_bundles/0': @field_name
'settings/handler_settings/auto_create': 'constants/auto_create'
......
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