Skip to content

Commit ae2ab3c

Browse files
committed
TASK: Refactor all parser tests, so they inherit from base test case
1 parent 14f6044 commit ae2ab3c

File tree

17 files changed

+514
-1727
lines changed

17 files changed

+514
-1727
lines changed

src/Language/Parser/Match/MatchCouldNotBeParsed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function becauseOfInvalidMatchArmNodes(
3838
'Match could not be parsed because of invalid match arm nodes: %s.',
3939
$cause->getMessage()
4040
),
41-
affectedRangeInSource: $affectedRangeInSource ?? $cause->affectedRangeInSource,
41+
affectedRangeInSource: $cause->affectedRangeInSource ?? $affectedRangeInSource,
4242
cause: $cause
4343
);
4444
}

test/Unit/Language/Parser/BooleanLiteral/BooleanLiteralParserTest.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* PackageFactory.ComponentEngine - Universal View Components for PHP
5-
* Copyright (C) 2022 Contributors of PackageFactory.ComponentEngine
5+
* Copyright (C) 2023 Contributors of PackageFactory.ComponentEngine
66
*
77
* This program is free software: you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
@@ -24,27 +24,20 @@
2424

2525
use PackageFactory\ComponentEngine\Language\AST\Node\BooleanLiteral\BooleanLiteralNode;
2626
use PackageFactory\ComponentEngine\Language\Parser\BooleanLiteral\BooleanLiteralParser;
27-
use PackageFactory\ComponentEngine\Parser\Source\Range;
28-
use PackageFactory\ComponentEngine\Parser\Source\Position;
29-
use PackageFactory\ComponentEngine\Parser\Source\Source;
30-
use PackageFactory\ComponentEngine\Parser\Tokenizer\Tokenizer;
31-
use PHPUnit\Framework\TestCase;
27+
use PackageFactory\ComponentEngine\Test\Unit\Language\Parser\ParserTestCase;
3228

33-
final class BooleanLiteralParserTest extends TestCase
29+
final class BooleanLiteralParserTest extends ParserTestCase
3430
{
3531
/**
3632
* @test
3733
*/
38-
public function producesAstNodeForTrueIfGivenOneTrueToken(): void
34+
public function parsesTrue(): void
3935
{
4036
$booleanLiteralParser = new BooleanLiteralParser();
41-
$tokens = Tokenizer::fromSource(Source::fromString('true'))->getIterator();
37+
$tokens = $this->createTokenIterator('true');
4238

4339
$expectedBooleanLiteralNode = new BooleanLiteralNode(
44-
rangeInSource: Range::from(
45-
new Position(0, 0),
46-
new Position(0, 3)
47-
),
40+
rangeInSource: $this->range([0, 0], [0, 3]),
4841
value: true
4942
);
5043

@@ -57,16 +50,13 @@ public function producesAstNodeForTrueIfGivenOneTrueToken(): void
5750
/**
5851
* @test
5952
*/
60-
public function producesAstNodeForFalseIfGivenOneFalseToken(): void
53+
public function parsesFalse(): void
6154
{
6255
$booleanLiteralParser = new BooleanLiteralParser();
63-
$tokens = Tokenizer::fromSource(Source::fromString('false'))->getIterator();
56+
$tokens = $this->createTokenIterator('false');
6457

6558
$expectedBooleanLiteralNode = new BooleanLiteralNode(
66-
rangeInSource: Range::from(
67-
new Position(0, 0),
68-
new Position(0, 4)
69-
),
59+
rangeInSource: $this->range([0, 0], [0, 4]),
7060
value: false
7161
);
7262

0 commit comments

Comments
 (0)