2016-09-30 11:08:52 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2016-10-03 11:39:21 +00:00
|
|
|
namespace LanguageServer\Tests;
|
2016-09-30 11:08:52 +00:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use LanguageServer\Formatter;
|
|
|
|
|
|
|
|
class FormatterTest extends TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
public function testFormat()
|
|
|
|
{
|
|
|
|
$formatter = new Formatter();
|
2016-10-10 08:46:22 +00:00
|
|
|
|
2016-09-30 11:08:52 +00:00
|
|
|
$input = file_get_contents(__DIR__ . '/../fixtures/format.php');
|
|
|
|
$output = file_get_contents(__DIR__ . '/../fixtures/format_expected.php');
|
2016-10-10 08:46:22 +00:00
|
|
|
|
2016-10-04 09:53:50 +00:00
|
|
|
$edits = $formatter->format($input, 'whatever');
|
2016-10-10 08:46:22 +00:00
|
|
|
$this->assertSame($output, $edits[0]->newText);
|
2016-09-30 11:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testFormatNoChange()
|
|
|
|
{
|
|
|
|
$formatter = new Formatter();
|
|
|
|
$expected = file_get_contents(__DIR__ . '/../fixtures/format_expected.php');
|
2016-10-10 08:46:22 +00:00
|
|
|
|
2016-10-04 09:53:50 +00:00
|
|
|
$edits = $formatter->format($expected, 'whatever');
|
2016-10-10 08:46:22 +00:00
|
|
|
$this->assertSame([], $edits);
|
2016-09-30 11:08:52 +00:00
|
|
|
}
|
2016-10-10 08:46:22 +00:00
|
|
|
}
|