You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::render() creates it's return value by calling \IntlDateFormatter::formatObject($date, $format);.
Please note that formatObject() is called without the optional third parameter specifying the locale, which means that the default ICU locale will be used.
Here is the method signature from the PHP manual:
If the third locale is not specified as an argument, the default ICU locale is used.
If no default locale is set, this value will default to the system default.
This causes the test \Magento\Reports\Test\Unit\Block\Adminhtml\Sales\Grid\Column\Renderer\DateTest::testRender() to fail sometimes, because it depends on the system locale.
If the system locale is set to a en_US locale the test is green. If it is a non-english locale, the test fails, because the expected output does not match the expected format:
% vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist --filter 'testRender.+#4' app/code/Magento/Reports/Test/Unit/Block/Adminhtml/Sales/Grid/Column/Renderer/DateTest.php
PHPUnit 4.1.0 by Sebastian Bergmann.
Configuration read from dev/tests/unit/phpunit.xml
F
Time: 58 ms, Memory: 6.75Mb
There was 1 failure:
1) Magento\Reports\Test\Unit\Block\Adminhtml\Sales\Grid\Column\Renderer\DateTest::testRender with data set #4 ('2014-06-25', 'en_US', 'period', 'day', 'Jun 25, 2014')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Jun 25, 2014'
+'Juni 25, 2014'
The above output is from a dev machine where the system locale is set as follows
% echo$LANG
de_DE.UTF-8
To summarize:
The date format is correctly constructed for a given locale.
However, the date constants rendered do not necessarily match that locale.
Possible fixes:
The locale is set as global state using \Locale::setDefault($locale).
The locale to has to be passed as to \IntlDateFormatter::formatObject() as a third argument.
Given the problems global state brings with it option number two would clearly be better.
The text was updated successfully, but these errors were encountered:
The method
\Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date::render()
creates it's return value by calling\IntlDateFormatter::formatObject($date, $format);
.Please note that
formatObject()
is called without the optional third parameter specifying the locale, which means that the default ICU locale will be used.Here is the method signature from the PHP manual:
If the third locale is not specified as an argument, the default ICU locale is used.
If no default locale is set, this value will default to the system default.
This causes the test
\Magento\Reports\Test\Unit\Block\Adminhtml\Sales\Grid\Column\Renderer\DateTest::testRender()
to fail sometimes, because it depends on the system locale.If the system locale is set to a en_US locale the test is green. If it is a non-english locale, the test fails, because the expected output does not match the expected format:
The above output is from a dev machine where the system locale is set as follows
To summarize:
The date format is correctly constructed for a given locale.
However, the date constants rendered do not necessarily match that locale.
Possible fixes:
\Locale::setDefault($locale)
.\IntlDateFormatter::formatObject()
as a third argument.Given the problems global state brings with it option number two would clearly be better.
The text was updated successfully, but these errors were encountered: