packages/sql-semantics-mysql/tests/Unit/Lowering/Replication/UntilRuleTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Lowering\Replication;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Lowering\Replication\UntilRule;
11use SqlSemantics\Platform\MySql\Semantics;
12
13#[CoversClass(UntilRule::class)]
14#[Medium]
15final class UntilRuleTest extends TestCase
16{
17    public function testUntilLowersAnAbsentAndAWrittenClause(): void
18    {
19        self::assertSame('START SLAVE', (new Semantics('mysql-5.6.51'))->analyze('start slave')->toString());
20        self::assertSame("START SLAVE UNTIL SQL_BEFORE_GTIDS = 'g'", (new Semantics('mysql-5.6.51'))->analyze("start slave until sql_before_gtids = 'g'")->toString());
21    }
22
23    public function testConditionsKeepsThePositionsInOrder(): void
24    {
25        self::assertSame("START REPLICA UNTIL RELAY_LOG_POS = 4, RELAY_LOG_FILE = 'r', SOURCE_LOG_POS = 5", (new Semantics())->analyze("start replica until relay_log_pos = 4, relay_log_file = 'r', source_log_pos = 5")->toString());
26    }
27}
28