Skip to content

Commit

Permalink
ENGCOM-8000: fix fatal error when exception was thrown #29483
Browse files Browse the repository at this point in the history
 - Merge Pull Request #29483 from rafal-kos/magento2:fix-timezone-exception-issue
 - Merged commits:
   1. 8b8e496
  • Loading branch information
magento-engcom-team committed Aug 17, 2020
2 parents 4930963 + 8b8e496 commit 710e381
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 710e381

Please sign in to comment.