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.
30 lines
840 B
PHP
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);
|
|
}
|
|
}
|