[Form] DateTimeToRfc3339Transformer use proper transformation exteption in reverse transformation
This commit is contained in:
parent
c8bd45b2c7
commit
7fc429ffd0
@ -53,7 +53,11 @@ class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$dateTime = new \DateTime($rfc3339);
|
||||
} catch (\Exception $e) {
|
||||
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
if ($this->outputTimezone !== $this->inputTimezone) {
|
||||
try {
|
||||
|
@ -119,4 +119,14 @@ class DateTimeToRfc3339TransformerTest extends DateTimeTestCase
|
||||
|
||||
$transformer->reverseTransform('2010-04-31T04:05Z');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testReverseTransformExpectsValidDateString()
|
||||
{
|
||||
$transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC');
|
||||
|
||||
$transformer->reverseTransform('2010-2010-2010');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user