packages/sql-semantics-mysql/tests/Unit/Statement/Replication/Replica/StopReplicaTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Replication\Replica;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Statement\Operation;
11use SqlSemantics\Platform\MySql\Semantics;
12use SqlSemantics\Platform\MySql\Statement\Literal\Text;
13use SqlSemantics\Platform\MySql\Statement\Replication\Replica\StopReplica;
14use SqlSemantics\Platform\MySql\Statement\Replication\Terminology;
15
16#[CoversClass(StopReplica::class)]
17#[Medium]
18final class StopReplicaTest extends TestCase
19{
20 public function testDeriveStatementRejectsAChannelOfMySql56(): void
21 {
22 $this->expectExceptionMessage('A replication channel needs MySQL 5.7 or later.');
23
24 new Operation((new Semantics('mysql-5.6.51'))->context([]), new StopReplica(Terminology::Legacy, [], new Text('c')));
25 }
26
27 public function testRenderWritesTheThreads(): void
28 {
29 self::assertSame('STOP REPLICA SQL_THREAD, IO_THREAD', (new Semantics())->analyze('stop replica sql_thread, relay_thread')->toString());
30 }
31}
32