assertInstanceOf('DateTimeZone', $tz); } catch (\Exception $e) { if (false !== strpos($e->getMessage(), 'Unknown or bad timezone')) { $this->markTestSkipped($timezoneName.' is not (yet) supported in this PHP version. Update pecl/timezonedb'); } else { throw $e; } } } public function getMapping() { TimeZoneUtil::loadTzMaps(); // PHPUNit requires an array of arrays return array_map( function ($value) { return [$value]; }, TimeZoneUtil::$map ); } public function testExchangeMap() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } public function testWetherMicrosoftIsStillInsane() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } public function testUnknownExchangeId() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } public function testWindowsTimeZone() { $tz = TimeZoneUtil::getTimeZone('Eastern Standard Time'); $ex = new \DateTimeZone('America/New_York'); $this->assertEquals($ex->getName(), $tz->getName()); } /** * @dataProvider getPHPTimeZoneIdentifiers */ public function testTimeZoneIdentifiers($tzid) { $tz = TimeZoneUtil::getTimeZone($tzid); $ex = new \DateTimeZone($tzid); $this->assertEquals($ex->getName(), $tz->getName()); } /** * @dataProvider getPHPTimeZoneBCIdentifiers */ public function testTimeZoneBCIdentifiers($tzid) { $tz = TimeZoneUtil::getTimeZone($tzid); $ex = new \DateTimeZone($tzid); $this->assertEquals($ex->getName(), $tz->getName()); } public function getPHPTimeZoneIdentifiers() { // PHPUNit requires an array of arrays return array_map( function ($value) { return [$value]; }, \DateTimeZone::listIdentifiers() ); } public function getPHPTimeZoneBCIdentifiers() { // PHPUNit requires an array of arrays return array_map( function ($value) { return [$value]; }, TimeZoneUtil::getIdentifiersBC() ); } public function testTimezoneOffset() { $tz = TimeZoneUtil::getTimeZone('GMT-0400', null, true); if (version_compare(PHP_VERSION, '5.5.10', '>=') && !defined('HHVM_VERSION')) { $ex = new \DateTimeZone('-04:00'); } else { $ex = new \DateTimeZone('Etc/GMT-4'); } $this->assertEquals($ex->getName(), $tz->getName()); } /** * @expectedException \InvalidArgumentException */ public function testTimezoneFail() { $tz = TimeZoneUtil::getTimeZone('FooBar', null, true); } public function testFallBack() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } public function testLjubljanaBug() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } public function testWeirdSystemVLICs() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } public function testPrefixedOffsetExchangeIdentifier() { $tz = TimeZoneUtil::getTimeZone('(UTC-05:00) Eastern Time (US & Canada)'); $ex = new \DateTimeZone('America/New_York'); $this->assertEquals($ex->getName(), $tz->getName()); } }