-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathJsonLoggerTest.php
More file actions
91 lines (83 loc) · 3.11 KB
/
JsonLoggerTest.php
File metadata and controls
91 lines (83 loc) · 3.11 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
declare( strict_types=1 );
use Pest\Mutate\Mutation;
use Pest\Mutate\MutationSuite;
use Pest\Mutate\MutationTest;
use Pest\Mutate\MutationTestCollection;
use Pest\Mutate\Mutators\Equality\EqualToIdentical;
use Pest\Mutate\Support\MutationTestResult;
use Pest\Mutate\Support\Printers\DefaultPrinter;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Finder\SplFileInfo;
afterEach( function (): void {
@unlink( __DIR__ . '/mutation-output.json' );
} );
test( 'it can output to json', function () {
$logger = new \Pest\Mutate\Logging\JsonLogger( __DIR__ . '/mutation-output.json' );
$suite = new MutationSuite();
$suite->repository->add( new Mutation(
id: 'test-id',
file: new SplFileInfo( 'test.php', '', '' ),
mutator: EqualToIdentical::class,
startLine: 4,
endLine: 4,
diff: <<<'DIFF'
--- Expected
+++ Actual
@@ @@
<fg=gray></>
<fg=red>- return 1 == '1';</>
<fg=green>+ return 1 === '1';</>
<fg=gray></>
DIFF,
modifiedSourcePath: 'test-modified.php',
) );
$suite->repository->all()[0]->tests()[0]->updateResult( MutationTestResult::Tested );
$suite->trackStart();
$suite->trackFinish();
$logger->mutationSuiteFinished( $suite );
expect( __DIR__ . '/mutation-output.json' )->toBeReadableFile();
expect( file_get_contents( __DIR__ . '/mutation-output.json' ) )->json()->toMatchArray( [
'format' => 'pest',
'results' =>
[
[
'path' => false,
'count_total' => 1,
'count_not_run' => 0,
'count_timed_out' => 0,
'count_uncovered' => 0,
'count_untested' => 0,
'tests' =>
[
0 =>
[
'id' => 'test-id',
'duration' => 0,
'result' => 'tested',
'mutation' =>
[
'id' => 'test-id',
'mutator' => 'Pest\\Mutate\\Mutators\\Equality\\EqualToIdentical',
'start_line' => 4,
'end_line' => 4,
],
],
],
],
],
'stats' =>
[
'duration' => 0,
'score' => 100,
'tests' =>
[
'count_total' => 1,
'count_not_run' => 0,
'count_timed_out' => 0,
'count_uncovered' => 0,
'count_untested' => 0,
],
],
] );
} );