Skip to content

Commit f9ab91b

Browse files
committed
Merge branch 'MAGETWO-37822' of https://github.corp.ebay.com/magento-firedrakes/magento2ce into MAGETWO-28011
2 parents a44460c + 157cefd commit f9ab91b

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

app/code/Magento/Config/Model/Config/Source/Locale/Timezone.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111

1212
class Timezone implements \Magento\Framework\Option\ArrayInterface
1313
{
14+
/**
15+
* Timezones that works incorrect with php_intl extension
16+
*/
17+
const IGNORED_TIMEZONES = [
18+
'Antarctica/Troll',
19+
'Asia/Chita',
20+
'Asia/Srednekolymsk',
21+
'Pacific/Bougainville'
22+
];
23+
1424
/**
1525
* @var \Magento\Framework\Locale\ListsInterface
1626
*/
@@ -29,6 +39,14 @@ public function __construct(\Magento\Framework\Locale\ListsInterface $localeList
2939
*/
3040
public function toOptionArray()
3141
{
32-
return $this->_localeLists->getOptionTimezones();
42+
$timezones = $this->_localeLists->getOptionTimezones();
43+
$timezones = array_filter($timezones, function($value) {
44+
if (in_array($value['value'], static::IGNORED_TIMEZONES)) {
45+
return false;
46+
}
47+
return true;
48+
});
49+
50+
return $timezones;
3351
}
3452
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\Test\Unit\Model\Config\Locale;
7+
8+
class LoaderTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var \PHPUnit_Framework_MockObject_MockObject
12+
*/
13+
protected $listMock;
14+
15+
/**
16+
* @var \Magento\Config\Model\Config\Source\Locale\Timezone
17+
*/
18+
protected $model;
19+
20+
protected function setUp()
21+
{
22+
$this->listMock = $this->getMockBuilder('Magento\Framework\Locale\TranslatedLists')
23+
->disableOriginalConstructor()
24+
->getMock();
25+
$this->model = new \Magento\Config\Model\Config\Source\Locale\Timezone($this->listMock);
26+
}
27+
28+
public function testToOptionArray()
29+
{
30+
$list = \DateTimeZone::listIdentifiers();
31+
$preparedList = [];
32+
foreach ($list as $value) {
33+
$preparedList[] = ['value' => $value, 'label' => $value];
34+
}
35+
$this->listMock->expects($this->once())
36+
->method('getOptionTimezones')
37+
->willReturn($preparedList);
38+
$result = $this->model->toOptionArray();
39+
foreach ($result as $value) {
40+
if (in_array($value['value'], \Magento\Config\Model\Config\Source\Locale\Timezone::IGNORED_TIMEZONES)) {
41+
$this->fail('Locale ' . $value['value'] . ' shouldn\'t be presented');
42+
}
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)