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