Commit 148b87f5 authored by catch's avatar catch

Issue #3011069 by Jo Fitzgerald, quietone: Incomplete testing for format_date process plugin

parent 2b94ed3c
......@@ -136,7 +136,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
throw new MigrateException(sprintf('Format date plugin could not transform "%s" using the format "%s". Error: %s', $value, $fromFormat, $e->getMessage()), $e->getCode(), $e);
}
catch (\UnexpectedValueException $e) {
throw new MigrateException(sprintf('Format date plugin could not transform "%s" using the format "%s". Error: %s', $value, $fromFormat, $e->getMessage()), $e->getCode(), $e);
throw new MigrateException(sprintf('Format date plugin could not transform "%s" using the format "%s" for destination "%s". Error: %s', $value, $fromFormat, $destination_property, $e->getMessage()), $e->getCode(), $e);
}
return $transformed;
......
......@@ -56,6 +56,20 @@ public function testMigrateExceptionBadFormat() {
$this->plugin->transform('January 5, 1955', $this->migrateExecutable, $this->row, 'field_date');
}
/**
* Tests that an unexpected date value will throw an exception.
*/
public function testMigrateExceptionUnexpectedValue() {
$configuration = [
'from_format' => 'm/d/Y',
'to_format' => 'Y-m-d',
];
$this->setExpectedException(MigrateException::class, 'Format date plugin could not transform "01/05/55" using the format "m/d/Y" for destination "field_date". Error: The created date does not match the input value.');
$this->plugin = new FormatDate($configuration, 'test_format_date', []);
$this->plugin->transform('01/05/55', $this->migrateExecutable, $this->row, 'field_date');
}
/**
* Tests that "timezone" configuration key triggers deprecation error.
*
......
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