Commit | Line | Data |
---|---|---|
1ea1fd20 TO |
1 | <?php |
2 | namespace Civi\CiUtil; | |
3 | ||
4 | /** | |
5 | * Parse phpunit result files | |
6 | */ | |
7 | class CSVParser { | |
8 | ||
9 | /** | |
04855556 TO |
10 | * @param string $csvContent |
11 | * Content; each row in the row csv should start with two cells:. | |
1ea1fd20 TO |
12 | * - cell 0: the test name |
13 | * - cell 1: the test status | |
a6c01b45 CW |
14 | * @return array |
15 | * (string $testName => string $status) | |
1ea1fd20 TO |
16 | */ |
17 | public static function parseResults($csvContent) { | |
18 | $fh = fopen('php://memory', 'r+'); | |
19 | fwrite($fh, $csvContent); | |
20 | rewind($fh); | |
21 | ||
c64f69d9 | 22 | $results = []; |
1ea1fd20 TO |
23 | while (($r = fgetcsv($fh)) !== FALSE) { |
24 | $name = str_replace('.', '::', trim($r[0])); | |
25 | $status = trim($r[1]); | |
26 | $results[$name] = $status; | |
27 | } | |
28 | ||
29 | return $results; | |
30 | } | |
31 | ||
ef10e0b5 | 32 | } |