/** * testListTimezones * * @return void */ public function testListTimezones() { $return = CakeTime::listTimezones(); $this->assertTrue(isset($return['Asia']['Asia/Bangkok'])); $this->assertEquals('Bangkok', $return['Asia']['Asia/Bangkok']); $this->assertTrue(isset($return['America']['America/Argentina/Buenos_Aires'])); $this->assertEquals('Argentina/Buenos_Aires', $return['America']['America/Argentina/Buenos_Aires']); $this->assertTrue(isset($return['UTC']['UTC'])); $this->assertFalse(isset($return['Cuba'])); $this->assertFalse(isset($return['US'])); $return = CakeTime::listTimezones('#^Asia/#'); $this->assertTrue(isset($return['Asia']['Asia/Bangkok'])); $this->assertFalse(isset($return['Pacific'])); $return = CakeTime::listTimezones('#^(America|Pacific)/#', null, false); $this->assertTrue(isset($return['America/Argentina/Buenos_Aires'])); $this->assertTrue(isset($return['Pacific/Tahiti'])); if (!$this->skipIf(version_compare(PHP_VERSION, '5.3.0', '<'))) { $return = CakeTime::listTimezones(DateTimeZone::ASIA); $this->assertTrue(isset($return['Asia']['Asia/Bangkok'])); $this->assertFalse(isset($return['Pacific'])); $return = CakeTime::listTimezones(DateTimeZone::PER_COUNTRY, 'US', false); $this->assertTrue(isset($return['Pacific/Honolulu'])); $this->assertFalse(isset($return['Asia/Bangkok'])); } }
/** * testListTimezones * * @return void */ public function testListTimezones() { $this->skipIf(version_compare(PHP_VERSION, '5.4.0', '<='), 'This test requires newer libicu which is in php5.4+'); $return = CakeTime::listTimezones(); $this->assertTrue(isset($return['Asia']['Asia/Bangkok'])); $this->assertEquals('Bangkok', $return['Asia']['Asia/Bangkok']); $this->assertTrue(isset($return['America']['America/Argentina/Buenos_Aires'])); $this->assertEquals('Argentina/Buenos_Aires', $return['America']['America/Argentina/Buenos_Aires']); $this->assertTrue(isset($return['UTC']['UTC'])); $this->assertFalse(isset($return['Cuba'])); $this->assertFalse(isset($return['US'])); $return = CakeTime::listTimezones('#^Asia/#'); $this->assertTrue(isset($return['Asia']['Asia/Bangkok'])); $this->assertFalse(isset($return['Pacific'])); $return = CakeTime::listTimezones(null, null, array('abbr' => true)); $this->assertTrue(isset($return['Asia']['Asia/Jakarta'])); $this->assertEquals('Jakarta - WIB', $return['Asia']['Asia/Jakarta']); $this->assertEquals('Regina - CST', $return['America']['America/Regina']); $return = CakeTime::listTimezones(null, null, array('abbr' => true, 'before' => ' (', 'after' => ')')); $this->assertEquals('Jayapura (WIT)', $return['Asia']['Asia/Jayapura']); $this->assertEquals('Regina (CST)', $return['America']['America/Regina']); $return = CakeTime::listTimezones('#^(America|Pacific)/#', null, false); $this->assertTrue(isset($return['America/Argentina/Buenos_Aires'])); $this->assertTrue(isset($return['Pacific/Tahiti'])); if (!$this->skipIf(version_compare(PHP_VERSION, '5.3.0', '<'))) { $return = CakeTime::listTimezones(DateTimeZone::ASIA); $this->assertTrue(isset($return['Asia']['Asia/Bangkok'])); $this->assertFalse(isset($return['Pacific'])); $return = CakeTime::listTimezones(DateTimeZone::PER_COUNTRY, 'US', false); $this->assertTrue(isset($return['Pacific/Honolulu'])); $this->assertFalse(isset($return['Asia/Bangkok'])); } }