packages/sql-semantics-mysql/tests/Unit/Statement/Replication/Log/PurgeLogsBeforeTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Replication\Log;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Semantics;
11use SqlSemantics\Platform\MySql\Statement\Replication\Log\PurgeLogsBefore;
12
13#[CoversClass(PurgeLogsBefore::class)]
14#[Medium]
15final class PurgeLogsBeforeTest extends TestCase
16{
17    public function testDeriveStatementDerivesTheMoment(): void
18    {
19        $purge = (new Semantics())->analyze("PURGE BINARY LOGS BEFORE '2024-01-01'");
20
21        self::assertInstanceOf(PurgeLogsBefore::class, $purge->statement);
22        self::assertSame([], $purge->facts->diagnostics);
23    }
24
25    public function testRenderWritesTheMoment(): void
26    {
27        self::assertSame("PURGE BINARY LOGS BEFORE '2024-01-01'", (new Semantics('mysql-5.6.51'))->analyze("purge master logs before '2024-01-01'")->toString());
28    }
29}
30