Beispiel #1
0
 public function executeRun()
 {
     set_time_limit(0);
     $buffer = tempnam(sys_get_temp_dir(), 'phpunit');
     $listener = new PHPUnit_Util_Log_JSON($buffer);
     $testResult = new PHPUnit_Framework_TestResult();
     $testResult->addListener($listener);
     $path = str_replace('-', '/', $this->getRequestParameter('test'));
     $loader = new sfPhpunitSuiteLoader($path);
     $loader->load();
     $loader->getSuite()->run($testResult);
     $result = '[' . str_replace('}{', '},{', file_get_contents($buffer)) . ']';
     $tests = array();
     foreach (json_decode($result) as $test) {
         if ('suiteStart' == $test->event) {
             continue;
         }
         if (!isset($tests[$test->suite])) {
             $tests[$test->suite]['methods'] = array();
             $tests[$test->suite]['status'] = 'pass';
         }
         $tests[$test->suite]['methods'][] = $test;
         if ('pass' != $test->status) {
             $tests[$test->suite]['status'] = 'fail';
         }
     }
     $this->result = $testResult;
     $this->tests = $tests;
     $this->path = $path;
 }