-
-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathJsonOutputFactoryTest.php
More file actions
47 lines (42 loc) · 1.69 KB
/
JsonOutputFactoryTest.php
File metadata and controls
47 lines (42 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace Rector\Tests\ChangesReporting\Output\Factory;
use PHPUnit\Framework\TestCase;
use Rector\ChangesReporting\Output\Factory\JsonOutputFactory;
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
use Rector\Php80\Rector\Identical\StrStartsWithRector;
use Rector\ValueObject\Configuration;
use Rector\ValueObject\Error\SystemError;
use Rector\ValueObject\ProcessResult;
use Rector\ValueObject\Reporting\FileDiff;
final class JsonOutputFactoryTest extends TestCase
{
public function testReportShouldShowNumberOfChangesWithNoDiffs(): void
{
$actualOutput = JsonOutputFactory::create(
new ProcessResult(
[new SystemError('Some error message', 'some/file.php', 1)],
[
new FileDiff(
'some/file.php',
'--- Original' . PHP_EOL . '+++ New' . PHP_EOL .
'@@ -38,5 +39,6 @@' . PHP_EOL .
'return true;' . PHP_EOL . '}' . PHP_EOL,
'diff console formatted',
[new RectorWithLineChange(StrStartsWithRector::class, 38)]
),
new FileDiff(
'some/file_foo.php',
'',
'',
[new RectorWithLineChange(StrStartsWithRector::class, 38)]
),
],
2
),
new Configuration(showDiffs: false)
);
$expectedOutput = (string) file_get_contents(__DIR__ . '/../Fixtures/without_diffs.json');
$this->assertSame($expectedOutput, $actualOutput);
}
}