2012-11-03 21:52:55 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Shared;
|
2012-11-03 21:52:55 +00:00
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Shared\TimeZone;
|
2017-11-08 15:48:01 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-08-14 04:08:43 +00:00
|
|
|
|
2017-11-08 15:48:01 +00:00
|
|
|
class TimeZoneTest extends TestCase
|
2012-11-03 21:52:55 +00:00
|
|
|
{
|
2020-05-18 04:49:57 +00:00
|
|
|
public function testSetTimezone(): void
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
2016-08-16 15:33:57 +00:00
|
|
|
$timezoneValues = [
|
2015-05-17 13:00:02 +00:00
|
|
|
'Europe/Prague',
|
|
|
|
'Asia/Tokyo',
|
|
|
|
'America/Indiana/Indianapolis',
|
|
|
|
'Pacific/Honolulu',
|
|
|
|
'Atlantic/St_Helena',
|
2016-08-16 15:33:57 +00:00
|
|
|
];
|
2015-05-17 13:00:02 +00:00
|
|
|
|
|
|
|
foreach ($timezoneValues as $timezoneValue) {
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = TimeZone::setTimezone($timezoneValue);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertTrue($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-03 21:52:55 +00:00
|
|
|
|
2020-05-18 04:49:57 +00:00
|
|
|
public function testSetTimezoneWithInvalidValue(): void
|
2015-05-17 13:00:02 +00:00
|
|
|
{
|
|
|
|
$unsupportedTimezone = 'Etc/GMT+10';
|
2016-08-26 06:39:29 +00:00
|
|
|
$result = TimeZone::setTimezone($unsupportedTimezone);
|
2017-09-20 05:55:42 +00:00
|
|
|
self::assertFalse($result);
|
2015-05-17 13:00:02 +00:00
|
|
|
}
|
2012-11-03 21:52:55 +00:00
|
|
|
}
|