public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariableWhenAvailable() { if ($this->isGreaterOrEqualThanPhpVersion('5.5.0-dev')) { $this->markTestSkipped('StubIntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); } $tz = getenv('TZ'); putenv('TZ=Europe/London'); $formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); $this->assertEquals($this->createDateTime(0, 'Europe/London')->format('Y-m-d H:i:s'), $formatter->format(0)); $this->assertEquals('Europe/London', getenv('TZ')); // Restores TZ. putenv('TZ=' . $tz); }
public function testFormatWithDefaultTimezoneStub() { $formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); $this->assertEquals($this->createDateTime(0)->format('Y-m-d H:i:s'), $formatter->format(0)); }
public function testFormatWithDefaultTimezoneStubShouldUseTheTzEnvironmentVariableWhenAvailable() { $tz = getenv('TZ'); putenv('TZ=Europe/London'); $formatter = new StubIntlDateFormatter('en', StubIntlDateFormatter::MEDIUM, StubIntlDateFormatter::SHORT); $formatter->setPattern('yyyy-MM-dd HH:mm:ss'); $this->assertEquals($this->createDateTime(0)->format('Y-m-d H:i:s'), $formatter->format(0)); $this->assertEquals('Europe/London', getenv('TZ')); // Restores TZ. putenv('TZ=' . $tz); }