Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tests/Unit/Errors/SyntaxErrorOtherTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace PHP_Parallel_Lint\PhpParallelLint\Tests\Unit\Errors;

use PHP_Parallel_Lint\PhpParallelLint\Blame;
use PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError;
use PHP_Parallel_Lint\PhpParallelLint\Tests\UnitTestCase;

class SyntaxErrorOtherTest extends UnitTestCase
{
/**
* Test setting and getting the blame.
*
* @covers \PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError::setBlame
* @covers \PHP_Parallel_Lint\PhpParallelLint\Errors\SyntaxError::getBlame
*
* @return void
*/
public function testGetSetBlame()
{
$blame = new Blame();
$error = new SyntaxError('test.php', 'message');

$error->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));
}
}