Conditions | 6 |
Paths | 4 |
Total Lines | 45 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Tests | 27 |
CRAP Score | 6 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
28 | 10 | public function __invoke(Activity $activity, Environment $env): void |
|
29 | { |
||
30 | if ( |
||
31 | 10 | !$activity->is(Type::sourcesModified()) && |
|
32 | 10 | !$activity->is(Type::testsModified()) |
|
33 | ) { |
||
34 | 2 | return; |
|
35 | } |
||
36 | |||
37 | 8 | $output = $env->output(); |
|
38 | 8 | $error = $env->error(); |
|
39 | |||
40 | $process = $this |
||
41 | 8 | ->processes |
|
42 | 8 | ->execute( |
|
43 | 8 | Command::foreground('vendor/bin/phpunit') |
|
44 | 8 | ->withOption('colors', 'always') |
|
45 | 8 | ->withWorkingDirectory((string) $env->workingDirectory()) |
|
46 | ); |
||
47 | $process |
||
48 | 8 | ->output() |
|
49 | ->foreach(static function(Str $line, Output\Type $type) use ($output, $error): void { |
||
50 | 4 | if ($type === Output\Type::output()) { |
|
51 | 4 | $output->write($line); |
|
52 | } else { |
||
53 | 4 | $error->write($line); |
|
54 | } |
||
55 | 8 | }); |
|
56 | 8 | $process->wait(); |
|
57 | |||
58 | 8 | if ($env->arguments()->contains('--silent')) { |
|
59 | 2 | return; |
|
60 | } |
||
61 | |||
62 | 6 | $successful = $process->exitCode()->isSuccessful(); |
|
63 | 6 | $text = 'PHPUnit : '; |
|
64 | 6 | $text .= $successful ? 'ok' : 'failing'; |
|
65 | |||
66 | $this |
||
67 | 6 | ->processes |
|
68 | 6 | ->execute( |
|
69 | 6 | Command::foreground('say') |
|
70 | 6 | ->withArgument($text) |
|
71 | ) |
||
72 | 6 | ->wait(); |
|
73 | 6 | } |
|
75 |