From cd6745ef3966a6f030c7971cd824bdfe5e433996 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 20 Feb 2022 19:39:48 +0100 Subject: [PATCH] Tests: add perfunctory tests for the remaining methods in `SyntaxError` --- tests/Unit/Errors/SyntaxErrorOtherTest.php | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/Unit/Errors/SyntaxErrorOtherTest.php diff --git a/tests/Unit/Errors/SyntaxErrorOtherTest.php b/tests/Unit/Errors/SyntaxErrorOtherTest.php new file mode 100644 index 0000000..a37a94e --- /dev/null +++ b/tests/Unit/Errors/SyntaxErrorOtherTest.php @@ -0,0 +1,45 @@ +setBlame($blame); + $this->assertSame($blame, $error->getBlame()); + } + + /** + * Test retrieving the error in Json serialized format. + * + * @covers \PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError::jsonSerialize + * + * @requires PHP 5.4 + * + * @return void + */ + public function testJsonSerialize() + { + // phpcs:ignore Generic.Files.LineLength.MaxExceeded + $expected = '{"type":"syntaxError","file":"path\/to\/file.php","line":2,"message":"Parse error: unexpected \'Foo\' (T_STRING) in file.php on line 2","normalizeMessage":"Unexpected \'Foo\' (T_STRING)","blame":null}'; + + $error = new SyntaxError('path/to/file.php', "Parse error: unexpected 'Foo' (T_STRING) in file.php on line 2"); + $this->assertJsonStringEqualsJsonString($expected, json_encode($error)); + } +}