packages/sql-semantics-mysql/tests/Unit/Statement/Replication/Reset/ResetBinaryLogsTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Replication\Reset;
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\Problem\RefusedSetting;
12use SqlSemantics\Platform\MySql\Statement\Replication\Problem\ReplicationError;
13use SqlSemantics\Platform\MySql\Statement\Replication\Reset\ResetBinaryLogs;
14
15#[CoversClass(ResetBinaryLogs::class)]
16#[Medium]
17final class ResetBinaryLogsTest extends TestCase
18{
19    public function testDeriveTargetReportsAFileNumberOutOfRange(): void
20    {
21        $reset = (new Semantics())->inspect('RESET BINARY LOGS AND GTIDS TO 0, BINARY LOGS AND GTIDS TO 2000000001, BINARY LOGS AND GTIDS TO 2000000000');
22
23        self::assertEquals([new RefusedSetting(ReplicationError::FileNumberOutOfRange), new RefusedSetting(ReplicationError::FileNumberOutOfRange)], $reset->facts->diagnostics);
24    }
25
26    public function testRenderKeepsMasterBeforeTheCurrentSpellingExists(): void
27    {
28        self::assertSame('RESET MASTER TO 7', (new Semantics('mysql-8.1.0'))->inspect('reset master to 7')->toString());
29    }
30}
31