Initial Release

This commit is contained in:
Jérôme Gamez
2021-12-10 16:09:27 +01:00
commit 10c02d2b49
28 changed files with 986 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace Beste\Clock\Tests;
use Beste\Clock\LocalizedClock;
use DateTimeZone;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
/**
* @internal
* @coversDefaultClass \Beste\Clock\LocalizedClock
*/
final class LocalizedClockTest extends TestCase
{
/**
* @test
* @covers ::in
*/
public function itRejectsAnInvalidTimeZone(): void
{
$this->expectException(InvalidArgumentException::class);
LocalizedClock::in('invalid');
}
/**
* @test
* @covers ::__construct
* @covers ::in
* @covers ::now
*/
public function itUsesTheGivenTimeZone(): void
{
$timeZone = new DateTimeZone('Asia/Bangkok');
$clock = LocalizedClock::in($timeZone);
$now = $clock->now();
self::assertSame($timeZone->getName(), $now->getTimezone()->getName());
}
/**
* @test
* @covers ::__construct
* @covers ::in
* @covers ::now
*/
public function itAcceptsTheTimeZoneAsAString(): void
{
$timeZone = 'Pacific/Guam';
$clock = LocalizedClock::in($timeZone);
$now = $clock->now();
self::assertSame($timeZone, $now->getTimezone()->getName());
}
}