diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php index 0791c89ab793a..42ffeae2aa883 100644 --- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php +++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php @@ -319,7 +319,7 @@ public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s') throw new LocalizedException( new Phrase( 'The DateTime object timezone needs to be the same as the "%1" timezone in config.', - $this->getConfigTimezone() + [$this->getConfigTimezone()] ) ); } diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php index b72995bb39855..09f85567e4c0d 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php @@ -9,6 +9,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ScopeResolverInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Locale\ResolverInterface; use Magento\Framework\Stdlib\DateTime; use Magento\Framework\Stdlib\DateTime\Timezone; @@ -208,6 +209,30 @@ public function testDate($expectedResult, $timezone, $date) ); } + /** + * Data provider for testException + * + * @return array + */ + public function getConvertConfigTimeToUTCDataFixtures() + { + return [ + 'datetime' => [ + new \DateTime('2016-10-10 10:00:00', new \DateTimeZone('UTC')) + ] + ]; + } + + /** + * @dataProvider getConvertConfigTimeToUTCDataFixtures + */ + public function testConvertConfigTimeToUtcException($date) + { + $this->expectException(LocalizedException::class); + + $this->getTimezone()->convertConfigTimeToUtc($date); + } + /** * DataProvider for testDate *