1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Paraunit\Printer; |
6
|
|
|
|
7
|
|
|
use Paraunit\Lifecycle\ProcessEvent; |
8
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class DebugPrinter |
12
|
|
|
* @package Paraunit\Printer |
13
|
|
|
*/ |
14
|
|
|
class DebugPrinter extends AbstractPrinter implements EventSubscriberInterface |
15
|
|
|
{ |
16
|
4 |
|
public static function getSubscribedEvents(): array |
17
|
|
|
{ |
18
|
|
|
return [ |
19
|
4 |
|
ProcessEvent::PROCESS_STARTED => 'onProcessStarted', |
20
|
|
|
ProcessEvent::PROCESS_TERMINATED => 'onProcessTerminated', |
21
|
|
|
ProcessEvent::PROCESS_PARSING_COMPLETED => ['onProcessParsingCompleted', 1], |
22
|
|
|
ProcessEvent::PROCESS_TO_BE_RETRIED => 'onProcessToBeRetried', |
23
|
|
|
]; |
24
|
|
|
} |
25
|
|
|
|
26
|
2 |
|
public function onProcessStarted(ProcessEvent $event) |
27
|
|
|
{ |
28
|
2 |
|
$process = $event->getProcess(); |
29
|
|
|
|
30
|
2 |
|
$this->getOutput()->writeln('PROCESS STARTED: ' . $process->getFilename()); |
31
|
2 |
|
$this->getOutput()->writeln($process->getCommandLine()); |
32
|
2 |
|
$this->getOutput()->writeln(''); |
33
|
|
|
} |
34
|
|
|
|
35
|
2 |
|
public function onProcessTerminated(ProcessEvent $event) |
36
|
|
|
{ |
37
|
2 |
|
$process = $event->getProcess(); |
38
|
|
|
|
39
|
2 |
|
$this->getOutput()->writeln(''); |
40
|
2 |
|
$this->getOutput()->writeln('PROCESS TERMINATED: ' . $process->getFilename()); |
41
|
2 |
|
$this->getOutput()->writeln(' - with class name: ' . $process->getTestClassName() ?? 'N/A'); |
42
|
2 |
|
$this->getOutput()->writeln(''); |
43
|
|
|
} |
44
|
|
|
|
45
|
2 |
|
public function onProcessParsingCompleted() |
46
|
|
|
{ |
47
|
2 |
|
$this->getOutput()->write('PROCESS PARSING COMPLETED -- RESULTS: '); |
48
|
|
|
} |
49
|
|
|
|
50
|
2 |
|
public function onProcessToBeRetried(ProcessEvent $event) |
51
|
|
|
{ |
52
|
2 |
|
$process = $event->getProcess(); |
53
|
|
|
|
54
|
2 |
|
$this->getOutput()->writeln(''); |
55
|
2 |
|
$this->getOutput()->writeln('PROCESS TO BE RETRIED: ' . $process->getFilename()); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|