diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php index 1f6e2f3..47d84a0 100644 --- a/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php +++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldTypeDefaults.php @@ -7,7 +7,7 @@ namespace Drupal\field\Plugin\migrate\process\d6; -use Drupal\migrate\MigrateException; +use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; @@ -30,7 +30,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $value = 'datetime_default'; } else { - throw new MigrateException(sprintf('Failed to lookup %s in the static map.', var_export($value, TRUE))); + throw new MigrateSkipRowException(); } } return $value; diff --git a/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php new file mode 100644 index 0000000..809912c --- /dev/null +++ b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d6/FieldTypeDefaultsTest.php @@ -0,0 +1,42 @@ +assertNull($plugin->transform(NULL, $this->migrateExecutable, $this->row, 'property')); + $this->assertEquals('string', $plugin->transform('string', $this->migrateExecutable, $this->row, 'property')); + $this->assertEquals(1234, $plugin->transform(1234, $this->migrateExecutable, $this->row, 'property')); + + $this->row->expects($this->once()) + ->method('getSourceProperty') + ->willReturn('date'); + $this->assertEquals('datetime_default', $plugin->transform([], $this->migrateExecutable, $this->row, 'property')); + } + + /** + * @expectedException \Drupal\migrate\MigrateSkipRowException + */ + public function testDefaultsException() { + $plugin = new FieldTypeDefaults([], 'field_type_defaults', []); + $plugin->transform([], $this->migrateExecutable, $this->row, 'property'); + } +}