public function testSetTimeZone()
{
$time = Time::get(time(), 'UTC');
$this->assertNotSame('Europe/Prague', $time->getTimeZone()->getName());
$time->setTimeZone('Europe/Prague');
$this->assertSame('Europe/Prague', $time->getTimeZone()->getName());
$timeZone = new \DateTimeZone('America/Santiago');
$time->setTimeZone($timeZone);
$this->assertSame('America/Santiago', $time->getTimeZone()->getName());
// Invalid timezone
try {
$time->setTimeZone('Foo/Bar');
$this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class));
} catch (\PHPUnit_Framework_AssertionFailedError $e) {
throw $e;
} catch (\Exception $e) {
// Correctly thrown exception
$this->assertInstanceOf(\InvalidArgumentException::class, $e);
}
}