diff --git a/src/View/Widget/DateTime.php b/src/View/Widget/DateTime.php index fe981b927a7..58408420c58 100644 --- a/src/View/Widget/DateTime.php +++ b/src/View/Widget/DateTime.php @@ -277,7 +277,7 @@ protected function _yearSelect($options = []) { if (empty($options['options'])) { $options['options'] = $this->_generateNumbers($options['start'], $options['end']); } - if ($options['order'] === 'asc') { + if ($options['order'] === 'desc') { $options['options'] = array_reverse($options['options'], true); } unset($options['start'], $options['end'], $options['order']); diff --git a/tests/TestCase/View/Widget/DateTimeTest.php b/tests/TestCase/View/Widget/DateTimeTest.php index dbf3bc74793..8a688829f1e 100644 --- a/tests/TestCase/View/Widget/DateTimeTest.php +++ b/tests/TestCase/View/Widget/DateTimeTest.php @@ -221,7 +221,7 @@ public function testRenderYearWidgetOrdering() { 'start' => 2013, 'end' => 2015, 'data-foo' => 'test', - 'order' => 'desc', + 'order' => 'asc', ], 'month' => false, 'day' => false, @@ -245,7 +245,7 @@ public function testRenderYearWidgetOrdering() { 'year' => [ 'start' => 2013, 'end' => 2015, - 'order' => 'asc' + 'order' => 'desc' ], 'month' => false, 'day' => false, @@ -287,12 +287,12 @@ public function testRenderYearWidgetValueOutOfBounds() { ]); $expected = [ 'select' => ['name' => 'date[year]'], - ['option' => ['value' => '2010', 'selected' => 'selected']], '2010', '/option', - ['option' => ['value' => '2011']], '2011', '/option', - ['option' => ['value' => '2012']], '2012', '/option', - ['option' => ['value' => '2013']], '2013', '/option', - ['option' => ['value' => '2014']], '2014', '/option', ['option' => ['value' => '2015']], '2015', '/option', + ['option' => ['value' => '2014']], '2014', '/option', + ['option' => ['value' => '2013']], '2013', '/option', + ['option' => ['value' => '2012']], '2012', '/option', + ['option' => ['value' => '2011']], '2011', '/option', + ['option' => ['value' => '2010', 'selected' => 'selected']], '2010', '/option', '/select', ]; $this->assertTags($result, $expected); @@ -313,10 +313,10 @@ public function testRenderYearWidgetValueOutOfBounds() { ]); $expected = [ 'select' => ['name' => 'date[year]'], - ['option' => ['value' => '2010']], '2010', '/option', - ['option' => ['value' => '2011']], '2011', '/option', - ['option' => ['value' => '2012']], '2012', '/option', ['option' => ['value' => '2013', 'selected' => 'selected']], '2013', '/option', + ['option' => ['value' => '2012']], '2012', '/option', + ['option' => ['value' => '2011']], '2011', '/option', + ['option' => ['value' => '2010']], '2010', '/option', '/select', ]; $this->assertTags($result, $expected);