Skip to content

Commit 8b8e496

Browse files
committed
fix fatal error when exception was thrown
1 parent 237c2b1 commit 8b8e496

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s')
319319
throw new LocalizedException(
320320
new Phrase(
321321
'The DateTime object timezone needs to be the same as the "%1" timezone in config.',
322-
$this->getConfigTimezone()
322+
[$this->getConfigTimezone()]
323323
)
324324
);
325325
}

lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111
use Magento\Framework\App\ScopeResolverInterface;
12+
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\Framework\Locale\ResolverInterface;
1314
use Magento\Framework\Stdlib\DateTime;
1415
use Magento\Framework\Stdlib\DateTime\Timezone;
@@ -208,6 +209,30 @@ public function testDate($expectedResult, $timezone, $date)
208209
);
209210
}
210211

212+
/**
213+
* Data provider for testException
214+
*
215+
* @return array
216+
*/
217+
public function getConvertConfigTimeToUTCDataFixtures()
218+
{
219+
return [
220+
'datetime' => [
221+
new \DateTime('2016-10-10 10:00:00', new \DateTimeZone('UTC'))
222+
]
223+
];
224+
}
225+
226+
/**
227+
* @dataProvider getConvertConfigTimeToUTCDataFixtures
228+
*/
229+
public function testConvertConfigTimeToUtcException($date)
230+
{
231+
$this->expectException(LocalizedException::class);
232+
233+
$this->getTimezone()->convertConfigTimeToUtc($date);
234+
}
235+
211236
/**
212237
* DataProvider for testDate
213238
*

0 commit comments

Comments
 (0)