/**
  * Runs tests based on the given TestSuite object.
  *
  * @param TestSuite $suite
  */
 public function run($suite)
 {
     $reporter = new MultipleReporter();
     $reporter->attachReporter($this->decorateReporter(new TextReporter()));
     if ($this->config->logsResultsInJUnitXML) {
         if (!$this->config->logsResultsInJUnitXMLInRealtime) {
             $xmlWriter = new Stagehand_TestRunner_JUnitXMLWriter_JUnitXMLDOMWriter(array($this, 'writeJUnitXMLToFile'));
         } else {
             $xmlWriter = $this->junitXMLStreamWriter(array($this, 'writeJUnitXMLToFile'));
         }
         $junitXMLReporter = new Stagehand_TestRunner_Runner_SimpleTestRunner_JUnitXMLReporter($this->config);
         $junitXMLReporter->setXMLWriter($xmlWriter);
         $junitXMLReporter->setTestSuite($suite);
         $junitXMLReporter->setConfig($this->config);
         $reporter->attachReporter($this->decorateReporter($junitXMLReporter));
     }
     ob_start();
     $suite->run($reporter);
     $output = ob_get_contents();
     ob_end_clean();
     if ($this->config->logsResultsInJUnitXML) {
         if (is_resource($this->junitXMLFileHandle)) {
             fclose($this->junitXMLFileHandle);
         }
     }
     if ($this->config->usesGrowl) {
         if (preg_match('/^(OK.+)/ms', $output, $matches)) {
             $this->notification->name = 'Green';
             $this->notification->description = $matches[1];
         } elseif (preg_match('/^(FAILURES.+)/ms', $output, $matches)) {
             $this->notification->name = 'Red';
             $this->notification->description = $matches[1];
         }
     }
     if ($this->config->colors) {
         print Console_Color::convert(preg_replace(array('/^(OK.+)/ms', '/^(FAILURES!!!.+)/ms', '/^(\\d+\\)\\s)(.+at \\[.+\\]$\\s+in .+)$/m', '/^(Exception \\d+!)/m', '/^(Unexpected exception of type \\[.+\\] with message \\[.+\\] in \\[.+\\]$\\s+in .+)$/m'), array('%g$1%n', '%r$1%n', "\$1%r\$2%n", '%p$1%n', '%p$1%n'), Console_Color::escape($output)));
     } else {
         print $output;
     }
 }
Пример #2
0
 /**
  * @param string $testName
  */
 public function paintMethodEnd($testName)
 {
     if ($this->shouldPaintMethod($testName)) {
         parent::paintMethodEnd($testName);
     }
 }