Skip to content
Snippets Groups Projects
Commit 148b87f5 authored by catch's avatar catch
Browse files

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

parent 2b94ed3c
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment