packages/sql-faker/tests/Unit/Generation/Derivation/DerivationNodeTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\SqlFaker\Generation\Derivation;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9use SqlFaker\Generation\Derivation\DerivationNode;
10use SqlFaker\Grammar\Model\NonTerminal;
11
12#[CoversClass(DerivationNode::class)]
13#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Grammar\Model\Grammar::class)]
14#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Grammar\Model\Production::class)]
15#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Grammar\Model\ProductionRule::class)]
16#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Grammar\Model\Terminal::class)]
17#[\PHPUnit\Framework\Attributes\UsesClass(NonTerminal::class)]
18#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\GrammarCoverageInventory::class)]
19#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\CoverageException::class)]
20#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\GrammarCoverage::class)]
21#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\GeneratorRevision::class)]
22#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\CoverageSnapshotStore::class)]
23#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\SnapshotValidation::class)]
24#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\GenerationTrace::class)]
25#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\CoverageSets::class)]
26#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Choice\ByteChoices::class)]
27#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Derivation\CompletionCosts::class)]
28#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFaker\Generation\Coverage\LexicalObservation::class)]
29final class DerivationNodeTest extends TestCase
30{
31 public function testSymbolRetainsAnOccurrenceWithoutChangingTheGrammarSymbol(): void
32 {
33 $symbol = new NonTerminal('expr');
34 $left = new DerivationNode($symbol, 1, 0, 0);
35 $right = new DerivationNode($symbol, 3, 0, 2);
36 self::assertSame($left->symbol, $right->symbol);
37 self::assertNotSame($left->nodeId, $right->nodeId);
38 self::assertSame(0, $right->parentNodeId);
39 self::assertSame(2, $right->rhsPosition);
40 }
41}
42