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