Files
preauth/tests/Unit/Core/ClockTest.php
T
andrew 647b445da7 Cline (powered by Kimi-K2.6) produced 18 test files, containing 127 tests with 243 assertions;
Which produce 28 errors, 11 failures, 59 deprecations, and 33 notices.
The tests cover 9 out of 21 classes, 54 out of 83 methods, and 237 out of 442 lines of code.
2026-06-04 14:02:56 -04:00

30 lines
840 B
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Unit\Core;
use App\Clock;
use PHPUnit\Framework\TestCase;
final class ClockTest extends TestCase {
public function testNowReturnsDateTimeImmutable(): void {
$clock = new Clock();
$before = new \DateTimeImmutable();
$now = $clock->now();
$after = new \DateTimeImmutable();
self::assertInstanceOf(\DateTimeImmutable::class, $now);
self::assertGreaterThanOrEqual($before->getTimestamp(), $now->getTimestamp());
self::assertLessThanOrEqual($after->getTimestamp(), $now->getTimestamp());
}
public function testNowReturnsDifferentInstances(): void {
$clock = new Clock();
$first = $clock->now();
usleep(1000);
$second = $clock->now();
self::assertNotSame($first, $second);
}
}