-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Kolb
committed
May 6, 2024
1 parent
a065718
commit f70fdbe
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Clock; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Moment; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(FrozenClock::class)] | ||
final class FrozenClockTest extends TestCase | ||
{ | ||
#[Test] | ||
public function freeze_works(): void | ||
{ | ||
// -- Arrange | ||
$clock = new FrozenClock(); | ||
$moment = Moment::fromStringInTimeZone('2024-05-06 08:00:00', new \DateTimeZone('Europe/Berlin')); | ||
|
||
// -- Act | ||
$clock->freeze($moment); | ||
|
||
// -- Assert | ||
self::assertSame($moment, $clock->now()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Clock; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Only very little that's possible to test here, so we do what's possible. | ||
*/ | ||
#[CoversClass(SystemClock::class)] | ||
final class SystemClockTest extends TestCase | ||
{ | ||
#[Test] | ||
public function now_works(): void | ||
{ | ||
// -- Arrange | ||
$clock = new SystemClock(); | ||
|
||
// -- Act | ||
$moment = $clock->now(); | ||
|
||
// -- Assert | ||
self::assertEquals($moment->dateTime->getTimezone(), new \DateTimeZone('UTC')); | ||
} | ||
} |