packages/sql-fixture/tests/Unit/Schema/DefinitionSegmentsTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Schema;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9use SqlFixture\Schema\DefinitionSegments as Subject;
10
11#[CoversClass(Subject::class)]
12final class DefinitionSegmentsTest extends TestCase
13{
14    public function testSplitKeepsQuotedCommasParenthesesAndDoubledQuotes(): void
15    {
16        self::assertSame(["label TEXT DEFAULT 'a,b(c)'", "note TEXT DEFAULT 'it''s, fine'", 'price NUMERIC(8,2)'], (new Subject())->split("label TEXT DEFAULT 'a,b(c)', note TEXT DEFAULT 'it''s, fine', price NUMERIC(8,2)"));
17    }
18
19    public function testSplitSkipsTrailingWhitespace(): void
20    {
21        self::assertSame(['id INT'], (new Subject())->split('id INT,  '));
22        self::assertSame([], (new Subject())->split(' '));
23    }
24}
25