assertInstanceOf('DateTimeZone', $tz); } catch (\Exception $e) { if (strpos($e->getMessage(), "Unknown or bad timezone")!==false) { $this->markTestSkipped($timezoneName . ' is not (yet) supported in this PHP version. Update pecl/timezonedb'); } else { throw $e; } } } function getMapping() { TimeZoneUtil::loadTzMaps(); // PHPUNit requires an array of arrays return array_map( function($value) { return array($value); }, TimeZoneUtil::$map ); } function testExchangeMap() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } function testWetherMicrosoftIsStillInsane() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } function testUnknownExchangeId() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } function testWindowsTimeZone() { $tz = TimeZoneUtil::getTimeZone('Eastern Standard Time'); $ex = new \DateTimeZone('America/New_York'); $this->assertEquals($ex->getName(), $tz->getName()); } /** * @dataProvider getPHPTimeZoneIdentifiers */ function testTimeZoneIdentifiers($tzid) { $tz = TimeZoneUtil::getTimeZone($tzid); $ex = new \DateTimeZone($tzid); $this->assertEquals($ex->getName(), $tz->getName()); } /** * @dataProvider getPHPTimeZoneBCIdentifiers */ function testTimeZoneBCIdentifiers($tzid) { $tz = TimeZoneUtil::getTimeZone($tzid); $ex = new \DateTimeZone($tzid); $this->assertEquals($ex->getName(), $tz->getName()); } function getPHPTimeZoneIdentifiers() { // PHPUNit requires an array of arrays return array_map( function($value) { return array($value); }, \DateTimeZone::listIdentifiers() ); } function getPHPTimeZoneBCIdentifiers() { // PHPUNit requires an array of arrays return array_map( function($value) { return array($value); }, TimeZoneUtil::getIdentifiersBC() ); } 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 */ function testTimezoneFail() { $tz = TimeZoneUtil::getTimeZone('FooBar', null, true); } function testFallBack() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } function testLjubljanaBug() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } function testWeirdSystemVLICs() { $vobj = <<assertEquals($ex->getName(), $tz->getName()); } }