Commit | Line | Data |
---|---|---|
f03dc6b0 TO |
1 | <?php |
2 | namespace Civi\CiUtil; | |
3 | ||
4 | /** | |
5 | * Parse phpunit result files | |
6 | */ | |
7 | class PHPUnitParser { | |
34f3bbd9 | 8 | |
f03dc6b0 | 9 | /** |
04855556 TO |
10 | * @param string $content |
11 | * Phpunit streaming JSON. | |
72b3a70c CW |
12 | * @return array |
13 | * ["$class::$func" => $status] | |
f03dc6b0 TO |
14 | */ |
15 | protected static function parseJsonStream($content) { | |
16 | $content = '[' | |
c64f69d9 | 17 | . strtr($content, ["}{" => "},{"]) |
f03dc6b0 TO |
18 | . ']'; |
19 | return json_decode($content, TRUE); | |
20 | } | |
21 | ||
22 | /** | |
04855556 TO |
23 | * @param string $content |
24 | * Json stream. | |
a6c01b45 CW |
25 | * @return array |
26 | * (string $testName => string $status) | |
f03dc6b0 TO |
27 | */ |
28 | public static function parseJsonResults($content) { | |
29 | $records = self::parseJsonStream($content); | |
c64f69d9 | 30 | $results = []; |
f03dc6b0 TO |
31 | foreach ($records as $r) { |
32 | if ($r['event'] == 'test') { | |
33 | $results[$r['test']] = $r['status']; | |
34 | } | |
35 | } | |
36 | return $results; | |
37 | } | |
38 | ||
ef10e0b5 | 39 | } |