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

8.7.x
Nathaniel Catchpole 2018-11-20 12:37:12 +00:00
parent 2b94ed3c25
commit 148b87f5cf
2 changed files with 15 additions and 1 deletions

View File

@ -136,7 +136,7 @@ class FormatDate extends ProcessPluginBase {
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;

View File

@ -56,6 +56,20 @@ class FormatDateTest extends MigrateProcessTestCase {
$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.
*