From d01bc6b1dab4a6687f1a0b923e596760ec416cd0 Mon Sep 17 00:00:00 2001 From: Manu Gonzalez Rodriguez Date: Tue, 10 Oct 2017 17:43:06 +0200 Subject: [PATCH 1/2] getDateFormatWithLongYear --- app/code/Magento/Customer/Block/Widget/Dob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php index f8ee8fddf2ea2..037d24d065708 100644 --- a/app/code/Magento/Customer/Block/Widget/Dob.php +++ b/app/code/Magento/Customer/Block/Widget/Dob.php @@ -228,7 +228,7 @@ public function getHtmlExtraParams() */ public function getDateFormat() { - return $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT); + return $this->_localeDate->getDateFormatWithLongYear(); } /** From 02966575d7cc640e5cada569c56239d1baf1f882 Mon Sep 17 00:00:00 2001 From: Manu Gonzalez Rodriguez Date: Tue, 10 Oct 2017 22:14:21 +0200 Subject: [PATCH 2/2] Refactoring DobTest --- .../Customer/Test/Unit/Block/Widget/DobTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php index ea4498591e086..74b2c119784e6 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php @@ -33,7 +33,7 @@ class DobTest extends \PHPUnit\Framework\TestCase const YEAR = '2014'; // Value of date('Y', strtotime(self::DATE)) - const DATE_FORMAT = 'M/d/yy'; + const DATE_FORMAT = 'M/d/Y'; /** Constants used by Dob::setDateInput($code, $html) */ const DAY_HTML = @@ -485,8 +485,8 @@ public function testGetHtmlExtraParamsWithoutRequiredOption() { $this->escaper->expects($this->any()) ->method('escapeHtml') - ->with('{"validate-date":{"dateFormat":"M\/d\/yy"}}') - ->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/yy"}}')); + ->with('{"validate-date":{"dateFormat":"M\/d\/Y"}}') + ->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/Y"}}')); $this->attribute->expects($this->once()) ->method("isRequired") @@ -494,7 +494,7 @@ public function testGetHtmlExtraParamsWithoutRequiredOption() $this->assertEquals( $this->_block->getHtmlExtraParams(), - 'data-validate="{"validate-date":{"dateFormat":"M\/d\/yy"}}"' + 'data-validate="{"validate-date":{"dateFormat":"M\/d\/Y"}}"' ); } @@ -506,14 +506,14 @@ public function testGetHtmlExtraParamsWithRequiredOption() $this->escaper->expects($this->any()) ->method('escapeHtml') - ->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}') - ->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}')); + ->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}') + ->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}')); $this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaper)); $this->assertEquals( - 'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}"', + 'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}"', $this->_block->getHtmlExtraParams() ); }