packages/sql-semantics-mysql/tests/Unit/Statement/Query/Into/IntoOutfileTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Query\Into;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Contract\GrammarRelease;
11use SqlSemantics\Platform\MySql\Model\Rendering\Lexical;
12use SqlSemantics\Platform\MySql\Model\Rendering\Output;
13use SqlSemantics\Platform\MySql\Rendering\Codec;
14use SqlSemantics\Platform\MySql\Statement\Dml\FileFormat;
15use SqlSemantics\Platform\MySql\Statement\Literal\Text;
16use SqlSemantics\Platform\MySql\Statement\Query\Into\IntoOutfile;
17
18#[CoversClass(IntoOutfile::class)]
19#[Small]
20final class IntoOutfileTest extends TestCase
21{
22 public function testRenderWritesTheFileAndTheFormat(): void
23 {
24 $format = self::createStub(FileFormat::class);
25 $outfile = new IntoOutfile(new Text('a.txt'), $format);
26 $out = new Output(new Codec(GrammarRelease::MySql847));
27 $outfile->render($out);
28
29 self::assertSame("OUTFILE 'a.txt'", (new Lexical())->join($out->pieces()));
30 self::assertSame($format, $outfile->format);
31 }
32}
33