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)); + } +}