public function transform($value)
{
if ($value === null) {
return '';
}
if (!$value instanceof \DateTime) {
throw new \InvalidArgumentException('Expected value of type \DateTime');
}
$value->setTimezone(new \DateTimeZone($this->getOption('output_timezone')));
return $value->format($this->getOption('format'));
}
public function testTransformExpectsDateTime() { $transformer = new DateTimeToStringTransformer(); $this->setExpectedException('Symfony\\Component\\Form\\Exception\\UnexpectedTypeException'); $transformer->transform('1234'); }