Skip to content
Permalink
Browse files

New test caught bug in _getMonthNames.

In implementing the test, a bug was caught. First unset the old value
then assign the new value, not the other way. Since when it gets to
October onwards, the old and new values are equal.

Also updated the test to look for values out of bounds, and fixed code formatting issues.
  • Loading branch information...
jhawkwind committed May 10, 2015
1 parent 8bbe2ad commit 30d2d8f785ecc7493e08637a1151396e732a0bd4
Showing with 18 additions and 3 deletions.
  1. +1 −1 src/View/Widget/DateTimeWidget.php
  2. +17 −2 tests/TestCase/View/Widget/DateTimeWidgetTest.php
@@ -525,8 +525,8 @@ protected function _getMonthNames($leadingZero = false)
if ($leadingZero === false) {
$i = 1;
foreach ($months as $key => $name) {
$months[$i++] = $name;
unset($months[$key]);
$months[$i++] = $name;
}
}
@@ -430,6 +430,7 @@ public function testRenderMonthWidgetWithNamesNoLeadingZeros()
'minute' => false,
'second' => false,
'month' => ['data-foo' => 'test', 'names' => true, 'leadingZeroKey' => false],
'meridian' => false,
'val' => $now,
], $this->context);
$expected = [
@@ -454,8 +455,22 @@ public function testRenderMonthWidgetWithNamesNoLeadingZeros()
$result,
'no 01 in value'
);
}
$this->assertNotContains(
'value="0"',
$result,
'no 0 in value'
);
$this->assertNotContains(
'value="00"',
$result,
'no 00 in value'
);
$this->assertNotContains(
'value="13"',
$result,
'no 13 in value'
);
}
/**
* Test rendering month widget with names.

0 comments on commit 30d2d8f

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