packages/sql-semantics-mysql/tests/Unit/Statement/Call/ClockTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Call;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Rules\Call\TypeClass;
11use SqlSemantics\Platform\MySql\Statement\Call\Clock;
12
13#[CoversClass(Clock::class)]
14#[Small]
15final class ClockTest extends TestCase
16{
17 public function testPreciseTellsWhetherAPrecisionIsAccepted(): void
18 {
19 self::assertTrue(Clock::SystemDate->precise());
20 self::assertFalse(Clock::UtcDate->precise());
21 }
22
23 public function testResultAnswersTheTypeClass(): void
24 {
25 self::assertSame(TypeClass::Time, Clock::UtcTime->result());
26 self::assertSame(TypeClass::Date, Clock::CurrentDate->result());
27 }
28
29 public function testBareAnswersTheKeywordWithoutParentheses(): void
30 {
31 self::assertSame(['CURRENT_TIMESTAMP', 'CURRENT_TIME', null, 'UTC_TIME', 'UTC_TIMESTAMP', 'CURRENT_DATE', 'UTC_DATE'], array_map(static fn (Clock $clock): ?string => $clock->bare(), Clock::cases()));
32 }
33}
34