|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * PackageFactory.ComponentEngine - Universal View Components for PHP |
| 5 | + * Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +declare(strict_types=1); |
| 22 | + |
| 23 | +namespace PackageFactory\ComponentEngine\Test\Unit\Language\Parser\ValueReference; |
| 24 | + |
| 25 | +use PackageFactory\ComponentEngine\Domain\VariableName\VariableName; |
| 26 | +use PackageFactory\ComponentEngine\Language\AST\Node\ValueReference\ValueReferenceNode; |
| 27 | +use PackageFactory\ComponentEngine\Language\Parser\ValueReference\ValueReferenceParser; |
| 28 | +use PackageFactory\ComponentEngine\Language\AST\NodeAttributes\NodeAttributes; |
| 29 | +use PackageFactory\ComponentEngine\Parser\Source\Range; |
| 30 | +use PackageFactory\ComponentEngine\Parser\Source\Position; |
| 31 | +use PackageFactory\ComponentEngine\Parser\Source\Source; |
| 32 | +use PackageFactory\ComponentEngine\Parser\Tokenizer\Tokenizer; |
| 33 | +use PHPUnit\Framework\TestCase; |
| 34 | + |
| 35 | +final class ValueReferenceParserTest extends TestCase |
| 36 | +{ |
| 37 | + /** |
| 38 | + * @test |
| 39 | + */ |
| 40 | + public function parsesValueReference(): void |
| 41 | + { |
| 42 | + $valueReferenceParser = new ValueReferenceParser(); |
| 43 | + $tokens = Tokenizer::fromSource(Source::fromString('foo'))->getIterator(); |
| 44 | + |
| 45 | + $expectedValueReferenceNode = new ValueReferenceNode( |
| 46 | + attributes: new NodeAttributes( |
| 47 | + rangeInSource: Range::from( |
| 48 | + new Position(0, 0), |
| 49 | + new Position(0, 2) |
| 50 | + ) |
| 51 | + ), |
| 52 | + name: VariableName::from('foo') |
| 53 | + ); |
| 54 | + |
| 55 | + $this->assertEquals( |
| 56 | + $expectedValueReferenceNode, |
| 57 | + $valueReferenceParser->parse($tokens) |
| 58 | + ); |
| 59 | + } |
| 60 | +} |
0 commit comments