From fc3e8ef3496bcc7cb32c9ac0b459d5381e3435a8 Mon Sep 17 00:00:00 2001 From: roblou Date: Fri, 19 May 2017 10:55:22 -0700 Subject: [PATCH] Fix ParseErrorTests --- tests/Server/TextDocument/ParseErrorsTest.php | 99 ++++++++++++++----- 1 file changed, 74 insertions(+), 25 deletions(-) diff --git a/tests/Server/TextDocument/ParseErrorsTest.php b/tests/Server/TextDocument/ParseErrorsTest.php index f3a3d3b..68948ef 100644 --- a/tests/Server/TextDocument/ParseErrorsTest.php +++ b/tests/Server/TextDocument/ParseErrorsTest.php @@ -64,7 +64,55 @@ class ParseErrorsTest extends TestCase 'range' => [ 'start' => [ 'line' => 2, - 'character' => 10 + 'character' => 9 + ], + 'end' => [ + 'line' => 2, + 'character' => 9 + ] + ], + 'severity' => DiagnosticSeverity::ERROR, + 'code' => null, + 'source' => 'php', + 'message' => "'Name' expected." + ], + [ + 'range' => [ + 'start' => [ + 'line' => 2, + 'character' => 9 + ], + 'end' => [ + 'line' => 2, + 'character' => 9 + ] + ], + 'severity' => DiagnosticSeverity::ERROR, + 'code' => null, + 'source' => 'php', + 'message' => "'{' expected." + ], + [ + 'range' => [ + 'start' => [ + 'line' => 2, + 'character' => 9 + ], + 'end' => [ + 'line' => 2, + 'character' => 9 + ] + ], + 'severity' => DiagnosticSeverity::ERROR, + 'code' => null, + 'source' => 'php', + 'message' => "'}' expected." + ], + [ + 'range' => [ + 'start' => [ + 'line' => 2, + 'character' => 15 ], 'end' => [ 'line' => 2, @@ -74,32 +122,33 @@ class ParseErrorsTest extends TestCase 'severity' => DiagnosticSeverity::ERROR, 'code' => null, 'source' => 'php', - 'message' => "Syntax error, unexpected T_CLASS, expecting T_STRING" + 'message' => "'Name' expected." ]] ], json_decode(json_encode($this->args), true)); } - public function testParseErrorsWithOnlyStartLine() - { - $this->openFile(__DIR__ . '/../../../fixtures/namespace_not_first.php'); - $this->assertEquals([ - 'whatever', - [[ - 'range' => [ - 'start' => [ - 'line' => 4, - 'character' => 0 - ], - 'end' => [ - 'line' => 4, - 'character' => 0 - ] - ], - 'severity' => DiagnosticSeverity::ERROR, - 'code' => null, - 'source' => 'php', - 'message' => "Namespace declaration statement has to be the very first statement in the script" - ]] - ], json_decode(json_encode($this->args), true)); - } + // This diagnostic not yet implemented in tolerant-php-parser + // public function testParseErrorsWithOnlyStartLine() + // { + // $this->openFile(__DIR__ . '/../../../fixtures/namespace_not_first.php'); + // $this->assertEquals([ + // 'whatever', + // [[ + // 'range' => [ + // 'start' => [ + // 'line' => 4, + // 'character' => 0 + // ], + // 'end' => [ + // 'line' => 4, + // 'character' => 0 + // ] + // ], + // 'severity' => DiagnosticSeverity::ERROR, + // 'code' => null, + // 'source' => 'php', + // 'message' => "Namespace declaration statement has to be the very first statement in the script" + // ]] + // ], json_decode(json_encode($this->args), true)); + // } }