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