packages/sql-semantics-sqlite/tests/Unit/Model/Lowering/LeavesTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Model\Lowering;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\Sqlite\Model\Lowering\Leaves;
11use SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name;
12
13#[CoversClass(Leaves::class)]
14#[Small]
15final class LeavesTest extends TestCase
16{
17    public function testRecordReturnsTheValueItself(): void
18    {
19        $leaves = new Leaves();
20        $name = new Name('a');
21
22        self::assertSame($name, $leaves->record($name));
23    }
24
25    public function testAllAnswersEveryRecordedLeafInOrder(): void
26    {
27        $leaves = new Leaves();
28        $first = new Name('a');
29        $second = new Name('b');
30
31        $leaves->record($first);
32        $leaves->record($second);
33
34        self::assertSame([$first, $second], $leaves->all());
35        self::assertSame([], (new Leaves())->all());
36    }
37}
38