Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 8bbe2ad
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/TestCase/View/Widget/DateTimeWidgetTest.php
Expand Up @@ -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.
*
Expand Down

0 comments on commit 8bbe2ad

Please sign in to comment.