Skip to content

Commit

Permalink
[Form] DateTimeToRfc3339Transformer use proper transformation extepti…
Browse files Browse the repository at this point in the history
…on in reverse transformation
  • Loading branch information
kibao committed Apr 9, 2013
1 parent c8bd45b commit 7fc429f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -53,7 +53,11 @@ public function reverseTransform($rfc3339)
return null;
}

$dateTime = new \DateTime($rfc3339);
try {
$dateTime = new \DateTime($rfc3339);
} catch (\Exception $e) {
throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
}

if ($this->outputTimezone !== $this->inputTimezone) {
try {
Expand Down
Expand Up @@ -119,4 +119,14 @@ public function testReverseTransformWithNonExistingDate()

$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');
}
}

0 comments on commit 7fc429f

Please sign in to comment.