[Form] Fixed failing test
This commit is contained in:
parent
021de7270a
commit
2f6507ba18
@ -140,6 +140,17 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
|
||||
$outputTz = new \DateTimeZone($this->outputTimezone);
|
||||
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
|
||||
|
||||
$lastErrors = \DateTime::getLastErrors();
|
||||
|
||||
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
|
||||
throw new TransformationFailedException(
|
||||
implode(', ', array_merge(
|
||||
array_values($lastErrors['warnings']),
|
||||
array_values($lastErrors['errors'])
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
// On PHP versions < 5.3.8 we need to emulate the pipe operator
|
||||
// and reset parts not given in the format to their equivalent
|
||||
// of the UNIX base timestamp.
|
||||
@ -204,17 +215,6 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
|
||||
}
|
||||
}
|
||||
|
||||
$lastErrors = \DateTime::getLastErrors();
|
||||
|
||||
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
|
||||
throw new TransformationFailedException(
|
||||
implode(', ', array_merge(
|
||||
array_values($lastErrors['warnings']),
|
||||
array_values($lastErrors['errors'])
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->inputTimezone !== $this->outputTimezone) {
|
||||
$dateTime->setTimeZone(new \DateTimeZone($this->inputTimezone));
|
||||
}
|
||||
|
@ -876,8 +876,10 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
|
||||
public function testDateTimeWithEmptyValueOnTime()
|
||||
{
|
||||
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03', array(
|
||||
'input' => 'string',
|
||||
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '', 'minute' => '');
|
||||
|
||||
$form = $this->factory->createNamed('name', 'datetime', $data, array(
|
||||
'input' => 'array',
|
||||
'empty_value' => array('hour' => 'Change&Me', 'minute' => 'Change&Me'),
|
||||
'required' => false,
|
||||
));
|
||||
|
Reference in New Issue
Block a user