-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency of date renderer on global state locale
Summary == This patch introduces a test to reproduce the bug described in issue #1468. `\Magento\Reports\Test\Unit\Block\Adminhtml\Sales\Grid\Column\Renderer\DateTest::testDateIsRenderedIndependentOfSystemDefaultLocale` The existing test `testRender` was refactored a little to avoid code duplication with the new test. The patch also includes a fix for the issue, which simply is to pass the locale that was used to create the date format as a third argument to `\IntlDateFormatter::formatObject()`. The following contents of the commit message are a slightly abbreviated copy of the issue #1468. ----- 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](http://php.net/manual/en/intldateformatter.formatobject.php): ``` public static string IntlDateFormatter::formatObject ( object $object [, mixed $format = NULL [, string $locale = NULL ]] ) ``` 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. `` 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 to **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.
- Loading branch information
Showing
2 changed files
with
79 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters