@@ -193,8 +193,62 @@ public function testRenderYearWidgetOrdering() {
193
193
$ this ->assertTags ($ result , $ expected );
194
194
}
195
195
196
+ /**
197
+ * Test that a selected value outside of the chosen
198
+ * year boundary is also included as an option.
199
+ *
200
+ * @return void
201
+ */
196
202
public function testRenderYearWidgetValueOutOfBounds () {
197
- $ this ->markTestIncomplete ();
203
+ $ now = new \DateTime ('2010-01-01 12:00:00 ' );
204
+ $ result = $ this ->DateTime ->render ([
205
+ 'name ' => 'date ' ,
206
+ 'year ' => [
207
+ 'start ' => 2013 ,
208
+ 'end ' => 2015 ,
209
+ ],
210
+ 'month ' => false ,
211
+ 'day ' => false ,
212
+ 'hour ' => false ,
213
+ 'minute ' => false ,
214
+ 'second ' => false ,
215
+ 'val ' => $ now ,
216
+ ]);
217
+ $ expected = [
218
+ 'select ' => ['name ' => 'date[year] ' ],
219
+ ['option ' => ['value ' => '2010 ' , 'selected ' => 'selected ' ]], '2010 ' , '/option ' ,
220
+ ['option ' => ['value ' => '2011 ' ]], '2011 ' , '/option ' ,
221
+ ['option ' => ['value ' => '2012 ' ]], '2012 ' , '/option ' ,
222
+ ['option ' => ['value ' => '2013 ' ]], '2013 ' , '/option ' ,
223
+ ['option ' => ['value ' => '2014 ' ]], '2014 ' , '/option ' ,
224
+ ['option ' => ['value ' => '2015 ' ]], '2015 ' , '/option ' ,
225
+ '/select ' ,
226
+ ];
227
+ $ this ->assertTags ($ result , $ expected );
228
+
229
+ $ now = new \DateTime ('2013-01-01 12:00:00 ' );
230
+ $ result = $ this ->DateTime ->render ([
231
+ 'name ' => 'date ' ,
232
+ 'year ' => [
233
+ 'start ' => 2010 ,
234
+ 'end ' => 2011 ,
235
+ ],
236
+ 'month ' => false ,
237
+ 'day ' => false ,
238
+ 'hour ' => false ,
239
+ 'minute ' => false ,
240
+ 'second ' => false ,
241
+ 'val ' => $ now ,
242
+ ]);
243
+ $ expected = [
244
+ 'select ' => ['name ' => 'date[year] ' ],
245
+ ['option ' => ['value ' => '2010 ' ]], '2010 ' , '/option ' ,
246
+ ['option ' => ['value ' => '2011 ' ]], '2011 ' , '/option ' ,
247
+ ['option ' => ['value ' => '2012 ' ]], '2012 ' , '/option ' ,
248
+ ['option ' => ['value ' => '2013 ' , 'selected ' => 'selected ' ]], '2013 ' , '/option ' ,
249
+ '/select ' ,
250
+ ];
251
+ $ this ->assertTags ($ result , $ expected );
198
252
}
199
253
200
254
public function testRenderMonthWidget () {
0 commit comments