phpmyadmin/tests/unit/Clock/ClockTest.php
Maurício Meneghini Fauth efa8ce431b
Introduce support for PSR-20 ClockInterface
Related to https://github.com/phpmyadmin/phpmyadmin/pull/20030

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2026-01-19 19:22:53 -03:00

30 lines
680 B
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Clock;
use DateTimeImmutable;
use PhpMyAdmin\Clock\Clock;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function usleep;
#[CoversClass(Clock::class)]
final class ClockTest extends TestCase
{
public function testNow(): void
{
$clock = new Clock();
$before = new DateTimeImmutable();
usleep(2000);
$now = $clock->now();
usleep(2000);
$after = new DateTimeImmutable();
self::assertGreaterThan($before, $now);
self::assertLessThan($after, $now);
self::assertNotSame($clock->now(), $clock->now());
}
}