8000 [Form] Fixed failing test · symfony/symfony@2f6507b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f6507b

Browse files
committed
[Form] Fixed failing test
1 parent 021de72 commit 2f6507b

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ public function reverseTransform($value)
140140
$outputTz = new \DateTimeZone($this->outputTimezone);
141141
$dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz);
142142

143+
$lastErrors = \DateTime::getLastErrors();
144+
145+
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
146+
throw new TransformationFailedException(
147+
implode(', ', array_merge(
148+
array_values($lastErrors['warnings']),
149+
array_values($lastErrors['errors'])
150+
))
151+
);
152+
}
153+
143154
// On PHP versions < 5.3.8 we need to emulate the pipe operator
144155
// and reset parts not given in the format to their equivalent
145156
// of the UNIX base timestamp.
@@ -204,17 +215,6 @@ public function reverseTransform($value)
204215
}
205216
}
206217

207-
$lastErrors = \DateTime::getLastErrors();
208-
209-
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
210-
throw new TransformationFailedException(
211-
implode(', ', array_merge(
212-
array_values($lastErrors['warnings']),
213-
array_values($lastErrors['errors'])
214-
))
215-
);
216-
}
217-
218218
if ($this->inputTimezone !== $this->outputTimezone) {
219219
$dateTime->setTimeZone(new \DateTimeZone($this->inputTimezone));
220220
}

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,10 @@ public function testDateTimeWithEmptyValueGlobal()
876876

877877
public function testDateTimeWithEmptyValueOnTime()
878878
{
879-
$form = $this->factory->createNamed('name', 'datetime', '2011-02-03', array(
880-
'input' => 'string',
879+
$data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '', 'minute' => '');
880+
881+
$form = $this->factory->createNamed('name', 'datetime', $data, array(
882+
'input' => 'array',
881883
'empty_value' => array('hour' => 'Change&Me', 'minute' => 'Change&Me'),
882884
'required' => false,
883885
));

0 commit comments

Comments
 (0)
0