Example #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;
 }
 protected function execute($arguments = array(), $options = array())
 {
     //    $initTask = new sfPhpunitInitTask($this->dispatcher, $this->formatter);
     //    $initTask->run();
     chdir(sfConfig::get('sf_root_dir'));
     shell_exec('./symfony phpunit:init');
     $path = $arguments['test'];
     sfBasePhpunitTestSuite::setProjectConfiguration($this->configuration);
     $runner = new PHPUnit_TextUI_TestRunner();
     $runner->doRun(sfPhpunitSuiteLoader::factory($path)->getSuite());
 }
 protected function _initFixturesDirs(PHPUnit_Framework_TestSuite $suite = null)
 {
     if (null === $suite) {
         $suite = sfPhpunitSuiteLoader::factory()->getSuite();
     }
     foreach ($suite->tests() as $test) {
         //don't create fixtures directories for default created suite.
         if ('sfBasePhpunitTestSuite' === get_class($test)) {
             $this->_initFixturesDirs($test);
             continue;
         }
         if ($test instanceof sfPhpunitFixtureAggregator) {
             $this->_createDir($test->getCommonFixtureDir());
             $this->_createDir($test->getPackageFixtureDir());
             $this->_createDir($test->getOwnFixtureDir());
         }
         if ($test instanceof PHPUnit_Framework_TestSuite) {
             $this->_initFixturesDirs($test);
         }
     }
 }