diff --git a/tests/Rules/AbstractRuleTestCase.php b/tests/Rules/AbstractRuleTestCase.php index fc492844..715d5f2d 100644 --- a/tests/Rules/AbstractRuleTestCase.php +++ b/tests/Rules/AbstractRuleTestCase.php @@ -19,7 +19,7 @@ abstract class AbstractRuleTestCase extends TestCase { /** - * @param array> $expects + * @param array $expects */ protected function checkRule( RuleInterface $rule, @@ -51,8 +51,8 @@ protected function checkRule( $messages = $report->getFileViolations($filePath); - /** @var array> $messagePositions */ - $messagePositions = []; + /** @var array $messageIds */ + $messageIds = []; foreach ($messages as $message) { if (Violation::LEVEL_FATAL === $message->getLevel()) { $errorMessage = $message->getMessage(); @@ -64,10 +64,10 @@ protected function checkRule( static::fail($errorMessage); } - $messagePositions[] = [$message->getLine() ?? 0 => $message->getLinePosition()]; + $messageIds[] = $message->getIdentifier()->toString(); } - static::assertSame($expects, $messagePositions); + static::assertSame($expects, $messageIds); } private function generateFilePath(): string diff --git a/tests/Rules/Delimiter/BlockNameSpacing/BlockNameSpacingTest.php b/tests/Rules/Delimiter/BlockNameSpacing/BlockNameSpacingTest.php index 8129e850..22639101 100644 --- a/tests/Rules/Delimiter/BlockNameSpacing/BlockNameSpacingTest.php +++ b/tests/Rules/Delimiter/BlockNameSpacing/BlockNameSpacingTest.php @@ -12,10 +12,10 @@ final class BlockNameSpacingTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new BlockNameSpacingRule(), [ - [1 => 5], - [1 => 5], - [3 => 3], - [3 => 3], + 'BlockNameSpacing.After.BlockName:1:5', + 'BlockNameSpacing.Before.BlockName:1:5', + 'BlockNameSpacing.After.BlockName:3:3', + 'BlockNameSpacing.Before.BlockName:3:3', ]); } } diff --git a/tests/Rules/Delimiter/DelimiterSpacing/DelimiterSpacingTest.php b/tests/Rules/Delimiter/DelimiterSpacing/DelimiterSpacingTest.php index dbc011d8..1fb72741 100644 --- a/tests/Rules/Delimiter/DelimiterSpacing/DelimiterSpacingTest.php +++ b/tests/Rules/Delimiter/DelimiterSpacing/DelimiterSpacingTest.php @@ -12,10 +12,10 @@ final class DelimiterSpacingTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new DelimiterSpacingRule(), [ - [15 => 1], - [15 => 12], - [15 => 15], - [15 => 25], + 'DelimiterSpacing.After.BlockStart:15:1', + 'DelimiterSpacing.Before.BlockEnd:15:12', + 'DelimiterSpacing.After.BlockStart:15:15', + 'DelimiterSpacing.Before.BlockEnd:15:25', ]); } } diff --git a/tests/Rules/Fixtures/disable2.twig b/tests/Rules/Fixtures/disable2.twig index fbd4546e..3eec7145 100644 --- a/tests/Rules/Fixtures/disable2.twig +++ b/tests/Rules/Fixtures/disable2.twig @@ -2,12 +2,13 @@ {# twig-cs-fixer-disable Fake.Error:2:1 #} This comment disable for the first token of the line. {# twig-cs-fixer-disable Fake.Error:3:2 #} This comment disable for the second token of the line. => ERROR ON THIS LINE {# twig-cs-fixer-disable-line Fake.Error #} This comment disable for the line. +{# twig-cs-fixer-disable-line Foo.Error, Fake.Error #} This comment disable for the line. {# twig-cs-fixer-disable-line Fake.Error #} This comment disable for the line with "{ #" => ERROR ON THIS LINE {# twig-cs-fixer-disable-line Fake.Error::1 #} This comment disable for the first token of the line. {# twig-cs-fixer-disable-line Fake.Error::2 #} This comment disable for the second token of the line. => ERROR ON THIS LINE {# twig-cs-fixer-disable-line #} This comment disable for the line for every rule -{# this comment use twig-cs-fixer-disable but not at the start of the comment #} => ERROR ON THIS LINE +{# this comment use twig-cs-fixer-disable Fake.Error #} But not at the start of the comment => ERROR ON THIS LINE {# twig-cs-fixer-disable-next-line Fake.Error #} This comment disable for the first token of the next-line. => ERROR ON THIS LINE {# twig-cs-fixer-disable-next-line Fake.Error #} This comment disable for the next line. => ERROR ON THIS LINE diff --git a/tests/Rules/Operator/OperatorNameSpacing/OperatorNameSpacingTest.php b/tests/Rules/Operator/OperatorNameSpacing/OperatorNameSpacingTest.php index b02b61e1..bf98a17f 100644 --- a/tests/Rules/Operator/OperatorNameSpacing/OperatorNameSpacingTest.php +++ b/tests/Rules/Operator/OperatorNameSpacing/OperatorNameSpacingTest.php @@ -12,9 +12,9 @@ final class OperatorNameSpacingTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new OperatorNameSpacingRule(), [ - [2 => 13], - [3 => 13], - [4 => 10], + 'OperatorNameSpacing.Error.Operator:2:13', + 'OperatorNameSpacing.Error.Operator:3:13', + 'OperatorNameSpacing.Error.Operator:4:10', ]); } } diff --git a/tests/Rules/Operator/OperatorSpacing/OperatorSpacingTest.php b/tests/Rules/Operator/OperatorSpacing/OperatorSpacingTest.php index ffcd3609..0a9c208d 100644 --- a/tests/Rules/Operator/OperatorSpacing/OperatorSpacingTest.php +++ b/tests/Rules/Operator/OperatorSpacing/OperatorSpacingTest.php @@ -12,50 +12,50 @@ final class OperatorSpacingTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new OperatorSpacingRule(), [ - [1 => 5], - [1 => 5], - [2 => 5], - [2 => 5], - [3 => 5], - [3 => 5], - [4 => 5], - [4 => 5], - [5 => 5], - [5 => 5], - [6 => 5], - [6 => 5], - [7 => 5], - [7 => 5], - [8 => 7], - [8 => 7], - [9 => 10], - [9 => 10], - [9 => 19], - [9 => 19], - [10 => 5], - [10 => 5], - [11 => 4], - [12 => 11], - [12 => 11], - [13 => 11], - [13 => 11], - [14 => 7], - [14 => 7], - [15 => 7], - [15 => 7], - [19 => 5], - [19 => 5], - [20 => 5], - [20 => 5], - [22 => 6], - [33 => 10], - [33 => 10], - [35 => 13], - [35 => 13], - [36 => 13], - [36 => 13], - [37 => 13], - [37 => 13], + 'OperatorSpacing.After.Operator:1:5', + 'OperatorSpacing.Before.Operator:1:5', + 'OperatorSpacing.After.Operator:2:5', + 'OperatorSpacing.Before.Operator:2:5', + 'OperatorSpacing.After.Operator:3:5', + 'OperatorSpacing.Before.Operator:3:5', + 'OperatorSpacing.After.Operator:4:5', + 'OperatorSpacing.Before.Operator:4:5', + 'OperatorSpacing.After.Operator:5:5', + 'OperatorSpacing.Before.Operator:5:5', + 'OperatorSpacing.After.Operator:6:5', + 'OperatorSpacing.Before.Operator:6:5', + 'OperatorSpacing.After.Operator:7:5', + 'OperatorSpacing.Before.Operator:7:5', + 'OperatorSpacing.After.Operator:8:7', + 'OperatorSpacing.Before.Operator:8:7', + 'OperatorSpacing.After.Operator:9:10', + 'OperatorSpacing.Before.Operator:9:10', + 'OperatorSpacing.After.Operator:9:19', + 'OperatorSpacing.Before.Operator:9:19', + 'OperatorSpacing.After.Operator:10:5', + 'OperatorSpacing.Before.Operator:10:5', + 'OperatorSpacing.After.Operator:11:4', + 'OperatorSpacing.After.Operator:12:11', + 'OperatorSpacing.Before.Operator:12:11', + 'OperatorSpacing.After.Operator:13:11', + 'OperatorSpacing.Before.Operator:13:11', + 'OperatorSpacing.After.Operator:14:7', + 'OperatorSpacing.Before.Operator:14:7', + 'OperatorSpacing.After.Operator:15:7', + 'OperatorSpacing.Before.Operator:15:7', + 'OperatorSpacing.After.Operator:19:5', + 'OperatorSpacing.Before.Operator:19:5', + 'OperatorSpacing.After.Operator:20:5', + 'OperatorSpacing.Before.Operator:20:5', + 'OperatorSpacing.After.Operator:22:6', + 'OperatorSpacing.After.Operator:33:10', + 'OperatorSpacing.Before.Operator:33:10', + 'OperatorSpacing.After.Operator:35:13', + 'OperatorSpacing.Before.Operator:35:13', + 'OperatorSpacing.After.Operator:36:13', + 'OperatorSpacing.Before.Operator:36:13', + 'OperatorSpacing.After.Operator:37:13', + 'OperatorSpacing.Before.Operator:37:13', ]); } diff --git a/tests/Rules/Punctuation/PunctuationSpacing/PunctuationSpacingTest.php b/tests/Rules/Punctuation/PunctuationSpacing/PunctuationSpacingTest.php index 0356e1e8..9d9e8b5c 100644 --- a/tests/Rules/Punctuation/PunctuationSpacing/PunctuationSpacingTest.php +++ b/tests/Rules/Punctuation/PunctuationSpacing/PunctuationSpacingTest.php @@ -12,21 +12,21 @@ final class PunctuationSpacingTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new PunctuationSpacingRule(), [ - [3 => 4], - [3 => 10], - [4 => 4], - [4 => 10], - [4 => 16], - [4 => 22], - [4 => 28], - [5 => 12], - [5 => 16], - [5 => 20], - [5 => 24], - [6 => 6], - [6 => 6], - [7 => 12], - [7 => 15], + 'PunctuationSpacing.After.Punctuation:3:4', + 'PunctuationSpacing.Before.Punctuation:3:10', + 'PunctuationSpacing.After.Punctuation:4:4', + 'PunctuationSpacing.Before.Punctuation:4:10', + 'PunctuationSpacing.Before.Punctuation:4:16', + 'PunctuationSpacing.Before.Punctuation:4:22', + 'PunctuationSpacing.Before.Punctuation:4:28', + 'PunctuationSpacing.After.Punctuation:5:12', + 'PunctuationSpacing.Before.Punctuation:5:16', + 'PunctuationSpacing.Before.Punctuation:5:20', + 'PunctuationSpacing.Before.Punctuation:5:24', + 'PunctuationSpacing.After.Punctuation:6:6', + 'PunctuationSpacing.Before.Punctuation:6:6', + 'PunctuationSpacing.Before.Punctuation:7:12', + 'PunctuationSpacing.Before.Punctuation:7:15', ]); } } diff --git a/tests/Rules/Punctuation/TrailingCommaSingleLine/TrailingCommaSingleLineTest.php b/tests/Rules/Punctuation/TrailingCommaSingleLine/TrailingCommaSingleLineTest.php index f2eb4367..e8e8c6c1 100644 --- a/tests/Rules/Punctuation/TrailingCommaSingleLine/TrailingCommaSingleLineTest.php +++ b/tests/Rules/Punctuation/TrailingCommaSingleLine/TrailingCommaSingleLineTest.php @@ -12,9 +12,9 @@ final class TrailingCommaSingleLineTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new TrailingCommaSingleLineRule(), [ - [2 => 9], - [4 => 13], - [6 => 12], + 'TrailingCommaSingleLine.Error.Punctuation:2:9', + 'TrailingCommaSingleLine.Error.Punctuation:4:13', + 'TrailingCommaSingleLine.Error.Punctuation:6:12', ]); } } diff --git a/tests/Rules/RuleTest.php b/tests/Rules/RuleTest.php index 0e361604..dfdf2b48 100644 --- a/tests/Rules/RuleTest.php +++ b/tests/Rules/RuleTest.php @@ -152,7 +152,7 @@ public static function ignoredViolationsDataProvider(): iterable ]; yield [ __DIR__.'/Fixtures/disable2.twig', - [3, 6, 8, 10, 11, 13], + [3, 7, 9, 11, 12, 14], ]; } } diff --git a/tests/Rules/Whitespace/BlankEOF/BlankEOFTest.php b/tests/Rules/Whitespace/BlankEOF/BlankEOFTest.php index bc10b01a..23064cd4 100644 --- a/tests/Rules/Whitespace/BlankEOF/BlankEOFTest.php +++ b/tests/Rules/Whitespace/BlankEOF/BlankEOFTest.php @@ -12,11 +12,11 @@ final class BlankEOFTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new BlankEOFRule(), [ - [4 => 1], + 'BlankEOF.Error.Eof:4:1', ]); $this->checkRule(new BlankEOFRule(), [ - [2 => 7], + 'BlankEOF.Error.Eof:2:7', ], __DIR__.'/BlankEOFTest2.twig'); } @@ -25,7 +25,7 @@ public function testRuleForEmptyFile(): void $this->checkRule(new BlankEOFRule(), [], __DIR__.'/BlankEOFTest.empty.twig'); $this->checkRule(new BlankEOFRule(), [ - [3 => 1], + 'BlankEOF.Error.Eof:3:1', ], __DIR__.'/BlankEOFTest.empty2.twig'); } } diff --git a/tests/Rules/Whitespace/EmptyLines/EmptyLinesTest.php b/tests/Rules/Whitespace/EmptyLines/EmptyLinesTest.php index 86f17abe..198a89ca 100644 --- a/tests/Rules/Whitespace/EmptyLines/EmptyLinesTest.php +++ b/tests/Rules/Whitespace/EmptyLines/EmptyLinesTest.php @@ -12,9 +12,9 @@ final class EmptyLinesTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new EmptyLinesRule(), [ - [2 => 1], - [5 => 1], - [10 => 1], + 'EmptyLines.Error.Eol:2:1', + 'EmptyLines.Error.Eol:5:1', + 'EmptyLines.Error.Eol:10:1', ]); } } diff --git a/tests/Rules/Whitespace/Indent/IndentTest.php b/tests/Rules/Whitespace/Indent/IndentTest.php index e7b8bb35..978cb020 100644 --- a/tests/Rules/Whitespace/Indent/IndentTest.php +++ b/tests/Rules/Whitespace/Indent/IndentTest.php @@ -18,8 +18,8 @@ public function testConfiguration(): void public function testRule(): void { $this->checkRule(new IndentRule(), [ - [2 => 1], - [4 => 1], + 'Indent.Error.CommentTab:2:1', + 'Indent.Error.Tab:4:1', ]); } @@ -28,8 +28,8 @@ public function testRuleWithSpaceRatio(): void $this->checkRule( new IndentRule(2), [ - [2 => 1], - [4 => 1], + 'Indent.Error.CommentTab:2:1', + 'Indent.Error.Tab:4:1', ], __DIR__.'/IndentTest.twig', __DIR__.'/IndentTest.fixed2.twig', diff --git a/tests/Rules/Whitespace/TrailingSpace/TrailingSpaceTest.php b/tests/Rules/Whitespace/TrailingSpace/TrailingSpaceTest.php index 9c988c4d..6b5261cb 100644 --- a/tests/Rules/Whitespace/TrailingSpace/TrailingSpaceTest.php +++ b/tests/Rules/Whitespace/TrailingSpace/TrailingSpaceTest.php @@ -12,16 +12,16 @@ final class TrailingSpaceTest extends AbstractRuleTestCase public function testRule(): void { $this->checkRule(new TrailingSpaceRule(), [ - [2 => 33], - [4 => 23], + 'TrailingSpace.Error.CommentEol:2:33', + 'TrailingSpace.Error.Eol:4:23', ]); } public function testRuleWithTab(): void { $this->checkRule(new TrailingSpaceRule(), [ - [2 => 32], - [4 => 21], + 'TrailingSpace.Error.CommentEol:2:32', + 'TrailingSpace.Error.Eol:4:21', ], __DIR__.'/TrailingSpaceTest.tab.twig'); } @@ -34,7 +34,7 @@ public function testRuleWithEmptyFile(): void ); $this->checkRule(new TrailingSpaceRule(), [ - [1 => 2], + 'TrailingSpace.Error.Eol:1:2', ], __DIR__.'/TrailingSpaceTest.empty2.twig'); } }