Skip to content

Commit eeaa4dc

Browse files
committed
minor symfony#17248 [Form] fixed DateTimeType tests using "date_widget"="choice". (Adrien LUCAS)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes symfony#17248). Discussion ---------- [Form] fixed DateTimeType tests using "date_widget"="choice". | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT | Doc PR | no As said in the [documentation](http://symfony.com/doc/current/reference/forms/types/datetime.html#years), the default years available in the ``DateType`` go from five year before to five year after the current year. So now that it's 2016 all around, the tests which use the ``"date_widget"="choice"`` without defining a ``"years"`` option and tries to submit a date in 2010 are failing because 2010 is not in the default choice list. This PR fixes the issue by setting the ``"years"`` option to ``"2010"`` for each test that need it. It also remove unnecessary (and confusing) dummy data from some tests which were suffering the same issue but silently. Edit : The PHP 5.6 build on travis seems to fetch and run some old version of the tests. So it still fail on this build but not on the others anymore. Commits ------- be20e89 Fix Form's DateTimeType tests.
2 parents e738227 + be20e89 commit eeaa4dc

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function testSubmitDateTime()
2929
'model_timezone' => 'UTC',
3030
'view_timezone' => 'UTC',
3131
'date_widget' => 'choice',
32+
'years' => array(2010),
3233
'time_widget' => 'choice',
3334
'input' => 'datetime',
3435
));
@@ -57,6 +58,7 @@ public function testSubmitString()
5758
'view_timezone' => 'UTC',
5859
'input' => 'string',
5960
'date_widget' => 'choice',
61+
'years' => array(2010),
6062
'time_widget' => 'choice',
6163
));
6264

@@ -82,6 +84,7 @@ public function testSubmitTimestamp()
8284
'view_timezone' => 'UTC',
8385
'input' => 'timestamp',
8486
'date_widget' => 'choice',
87+
'years' => array(2010),
8588
'time_widget' => 'choice',
8689
));
8790

@@ -108,12 +111,13 @@ public function testSubmitWithoutMinutes()
108111
'model_timezone' => 'UTC',
109112
'view_timezone' => 'UTC',
110113
'date_widget' => 'choice',
114+
'years' => array(2010),
111115
'time_widget' => 'choice',
112116
'input' => 'datetime',
113117
'with_minutes' => false,
114118
));
115119

116-
$form->setData(new \DateTime('2010-06-02 03:04:05 UTC'));
120+
$form->setData(new \DateTime());
117121

118122
$input = array(
119123
'date' => array(
@@ -137,12 +141,13 @@ public function testSubmitWithSeconds()
137141
'model_timezone' => 'UTC',
138142
'view_timezone' => 'UTC',
139143
'date_widget' => 'choice',
144+
'years' => array(2010),
140145
'time_widget' => 'choice',
141146
'input' => 'datetime',
142147
'with_seconds' => true,
143148
));
144149

145-
$form->setData(new \DateTime('2010-06-02 03:04:05 UTC'));
150+
$form->setData(new \DateTime());
146151

147152
$input = array(
148153
'date' => array(
@@ -168,6 +173,7 @@ public function testSubmitDifferentTimezones()
168173
'model_timezone' => 'America/New_York',
169174
'view_timezone' => 'Pacific/Tahiti',
170175
'date_widget' => 'choice',
176+
'years' => array(2010),
171177
'time_widget' => 'choice',
172178
'input' => 'string',
173179
'with_seconds' => true,

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public function testSubmitFromChoice()
180180
'model_timezone' => 'UTC',
181181
'view_timezone' => 'UTC',
182182
'widget' => 'choice',
183+
'years' => array(2010),
183184
));
184185

185186
$text = array(

0 commit comments

Comments
 (0)