Skip to content
Permalink
Browse files

Added test for month widget with no leadingZeroKey

Added a test case for rendering the month widget without leading zeros
in the option value.
  • Loading branch information...
jhawkwind committed May 9, 2015
1 parent fa24100 commit 8bbe2adda0d17ea227da03412c112b6e11379333
Showing with 43 additions and 0 deletions.
  1. +43 −0 tests/TestCase/View/Widget/DateTimeWidgetTest.php
@@ -414,6 +414,49 @@ public function testRenderMonthWidget()
$this->assertHtml($expected, $result);
}
/**
* Test rendering month widget with names and values without leading zeros.
*
* @return void
*/
public function testRenderMonthWidgetWithNamesNoLeadingZeros()
{
$now = new \DateTime('2010-12-01 12:00:00');
$result = $this->DateTime->render([
'name' => 'date',
'year' => false,
'day' => false,
'hour' => false,
'minute' => false,
'second' => false,
'month' => ['data-foo' => 'test', 'names' => true, 'leadingZeroKey' => false],
'val' => $now,
], $this->context);
$expected = [
'select' => ['name' => 'date[month]', 'data-foo' => 'test'],
['option' => ['value' => '1']], 'January', '/option',
['option' => ['value' => '2']], 'February', '/option',
['option' => ['value' => '3']], 'March', '/option',
['option' => ['value' => '4']], 'April', '/option',
['option' => ['value' => '5']], 'May', '/option',
['option' => ['value' => '6']], 'June', '/option',
['option' => ['value' => '7']], 'July', '/option',
['option' => ['value' => '8']], 'August', '/option',
['option' => ['value' => '9']], 'September', '/option',
['option' => ['value' => '10']], 'October', '/option',
['option' => ['value' => '11']], 'November', '/option',
['option' => ['value' => '12', 'selected' => 'selected']], 'December', '/option',
'/select',
];
$this->assertHtml($expected, $result);
$this->assertNotContains(
'<option value="01">January</option>',
$result,
'no 01 in value'
);
}
/**
* Test rendering month widget with names.
*

0 comments on commit 8bbe2ad

Please sign in to comment.
You can’t perform that action at this time.