@@ -414,6 +414,49 @@ public function testRenderMonthWidget()
414
414
$ this ->assertHtml ($ expected , $ result );
415
415
}
416
416
417
+ /**
418
+ * Test rendering month widget with names and values without leading zeros.
419
+ *
420
+ * @return void
421
+ */
422
+ public function testRenderMonthWidgetWithNamesNoLeadingZeros ()
423
+ {
424
+ $ now = new \DateTime ('2010-12-01 12:00:00 ' );
425
+ $ result = $ this ->DateTime ->render ([
426
+ 'name ' => 'date ' ,
427
+ 'year ' => false ,
428
+ 'day ' => false ,
429
+ 'hour ' => false ,
430
+ 'minute ' => false ,
431
+ 'second ' => false ,
432
+ 'month ' => ['data-foo ' => 'test ' , 'names ' => true , 'leadingZeroKey ' => false ],
433
+ 'val ' => $ now ,
434
+ ], $ this ->context );
435
+ $ expected = [
436
+ 'select ' => ['name ' => 'date[month] ' , 'data-foo ' => 'test ' ],
437
+ ['option ' => ['value ' => '1 ' ]], 'January ' , '/option ' ,
438
+ ['option ' => ['value ' => '2 ' ]], 'February ' , '/option ' ,
439
+ ['option ' => ['value ' => '3 ' ]], 'March ' , '/option ' ,
440
+ ['option ' => ['value ' => '4 ' ]], 'April ' , '/option ' ,
441
+ ['option ' => ['value ' => '5 ' ]], 'May ' , '/option ' ,
442
+ ['option ' => ['value ' => '6 ' ]], 'June ' , '/option ' ,
443
+ ['option ' => ['value ' => '7 ' ]], 'July ' , '/option ' ,
444
+ ['option ' => ['value ' => '8 ' ]], 'August ' , '/option ' ,
445
+ ['option ' => ['value ' => '9 ' ]], 'September ' , '/option ' ,
446
+ ['option ' => ['value ' => '10 ' ]], 'October ' , '/option ' ,
447
+ ['option ' => ['value ' => '11 ' ]], 'November ' , '/option ' ,
448
+ ['option ' => ['value ' => '12 ' , 'selected ' => 'selected ' ]], 'December ' , '/option ' ,
449
+ '/select ' ,
450
+ ];
451
+ $ this ->assertHtml ($ expected , $ result );
452
+ $ this ->assertNotContains (
453
+ '<option value="01">January</option> ' ,
454
+ $ result ,
455
+ 'no 01 in value '
456
+ );
457
+
458
+ }
459
+
417
460
/**
418
461
* Test rendering month widget with names.
419
462
*
0 commit comments