commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / Civi / CiUtil / EnvTestRunner.php
1 <?php
2 namespace Civi\CiUtil;
3
4 /**
5 * Parse phpunit result files
6 */
7 class EnvTestRunner {
8 protected $phpunit;
9 protected $envTestSuite;
10
11 /**
12 * @param string $phpunit
13 * @param string $envTestSuite
14 */
15 public function __construct($phpunit = "phpunit", $envTestSuite = 'EnvTests') {
16 $this->phpunit = $phpunit;
17 $this->envTestSuite = $envTestSuite;
18 }
19
20 /**
21 * @param array $tests
22 * @return array
23 * (string $testName => string $status)
24 */
25 public function run($tests) {
26 $envTests = implode(' ', $tests);
27 $jsonFile = tempnam(sys_get_temp_dir(), 'phpunit-json-');
28 unlink($jsonFile);
29 $command = "env PHPUNIT_TESTS=\"$envTests\" {$this->phpunit} --log-json $jsonFile {$this->envTestSuite}";
30 echo "Running [$command]\n";
31 system($command);
32 $results = PHPUnitParser::parseJsonResults(file_get_contents($jsonFile));
33 unlink($jsonFile);
34 return $results;
35 }
36
37 }