Ejemplo n.º 1
0
 /**
  * A test ended.
  *
  * @param  PHPUnit2_Framework_Test $test
  * @access public
  */
 public function endTest(PHPUnit2_Framework_Test $test)
 {
     $this->log->info(sprintf('Test "%s" ended.', $test->getName()));
 }
Ejemplo n.º 2
0
 /**
  * A test ended.
  *
  * @param  PHPUnit2_Framework_Test $test
  * @access public
  */
 public function endTest(PHPUnit2_Framework_Test $test)
 {
     $prettifiedName = $this->prettifier->prettifyTestMethod($test->getName());
     if (!isset($this->tests[$prettifiedName])) {
         if (!$this->testFailed) {
             $this->tests[$prettifiedName]['success'] = 1;
             $this->tests[$prettifiedName]['failure'] = 0;
         } else {
             $this->tests[$prettifiedName]['success'] = 0;
             $this->tests[$prettifiedName]['failure'] = 1;
         }
     } else {
         if (!$this->testFailed) {
             $this->tests[$prettifiedName]['success']++;
         } else {
             $this->tests[$prettifiedName]['failure']++;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * A test ended.
  *
  * @param  PHPUnit2_Framework_Test  $test
  * @access public
  */
 public function endTest(PHPUnit2_Framework_Test $test)
 {
     $this->testEnded($test->getName());
 }
Ejemplo n.º 4
0
 /**
  * Informs the result that a test will be started.
  *
  * @param  PHPUnit2_Framework_Test $test
  * @access public
  */
 public function startTest(PHPUnit2_Framework_Test $test)
 {
     $this->runTests += $test->countTestCases();
     foreach ($this->listeners as $listener) {
         $listener->startTest($test);
     }
 }
Ejemplo n.º 5
0
 /**
  * @param  PHPUnit2_Framework_Test $suite
  * @param  boolean                 $wait
  * @return PHPUnit2_Framework_TestResult
  * @access public
  */
 public function doRun(PHPUnit2_Framework_Test $suite, $wait = false)
 {
     $result = $this->createTestResult();
     if ($this->printer === null) {
         $this->printer = new PHPUnit2_TextUI_ResultPrinter();
     }
     $this->printer->write(PHPUnit2_Runner_Version::getVersionString() . "\n\n");
     $result->addListener($this->printer);
     if (class_exists('Benchmark_Timer')) {
         $timer = new Benchmark_Timer();
     }
     if (isset($timer)) {
         $timer->start();
     }
     $suite->run($result);
     if (isset($timer)) {
         $timer->stop();
         $timeElapsed = $timer->timeElapsed();
     } else {
         $timeElapsed = false;
     }
     $this->pause($wait);
     $this->printer->printResult($result, $timeElapsed);
     return $result;
 }
Ejemplo n.º 6
0
 /**
  * Trys to get the original exception thrown by the test on failure/error 
  * to enable us to give a bit more detail about the failure/error
  * 
  * @access private
  * @param obj PHPUnit2_Framework_Test, current test that is being run
  * @param obj PHPUnit2_Framework_AssertationFailedError, PHPUnit2 error
  * @return array
  */
 private function getTestException(PHPUnit2_Framework_Test $test, Exception $e)
 {
     // get the name of the testFile from the test
     $testName = ereg_replace('(.*)\\((.*[^)])\\)', '\\2', $test->toString());
     $trace = $e->getTrace();
     // loop through the exception trace to find the original exception
     for ($i = 0; $i < count($trace); $i++) {
         if (array_key_exists('file', $trace[$i])) {
             if (stristr($trace[$i]['file'], $testName . '.php') != false) {
                 return $trace[$i];
             }
         }
         if (array_key_exists('file:protected', $trace[$i])) {
             if (stristr($trace[$i]['file:protected'], $testName . '.php') != false) {
                 return $trace[$i];
             }
         }
     }
 }
Ejemplo n.º 7
0
 public function startTest(PHPUnit2_Framework_Test $test)
 {
     echo '<tr>';
     $test->failed = false;
     echo '<td>' . $test->getName() . '</td>';
 }
Ejemplo n.º 8
0
 /**
  * Runs a test.
  *
  * @param  PHPUnit2_Framework_Test        $test
  * @param  PHPUnit2_Framework_TestResult  $testResult
  * @access public
  */
 public function runTest(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_TestResult $result)
 {
     $test->run($result);
 }
Ejemplo n.º 9
0
 /**
  * A test started.
  *
  * @param  PHPUnit2_Framework_Test  $test
  * @access public
  */
 public function startTest(PHPUnit2_Framework_Test $test)
 {
     $this->testStarted($test->getName());
 }
Ejemplo n.º 10
0
 /**
  * A test started.
  *
  * @param  PHPUnit2_Framework_Test $test
  * @access public
  */
 public function startTest(PHPUnit2_Framework_Test $test)
 {
     $testCase = $this->document->createElement('testcase');
     $testCase->setAttribute('name', $test->getName());
     $testCase->setAttribute('class', get_class($test));
     $this->testSuites[$this->testSuiteLevel]->appendChild($testCase);
     $this->currentTestCase = $testCase;
     $this->testSuiteTests[$this->testSuiteLevel]++;
     $this->timer->start();
 }
Ejemplo n.º 11
0
 /**
  * @param  PHPUnit2_Framework_Test $suite
  * @param  mixed                   $coverageDataFile
  * @param  mixed                   $coverageHTMLFile
  * @param  mixed                   $coverageTextFile
  * @param  mixed                   $testdoxHTMLFile
  * @param  mixed                   $testdoxTextFile
  * @param  mixed                   $xmlLogfile
  * @param  boolean                 $wait
  * @return PHPUnit2_Framework_TestResult
  * @access public
  */
 public function doRun(PHPUnit2_Framework_Test $suite, $coverageDataFile = FALSE, $coverageHTMLFile = FALSE, $coverageTextFile = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $xmlLogfile = FALSE, $wait = FALSE)
 {
     $result = $this->createTestResult();
     $timer = new Benchmark_Timer();
     if ($this->printer === NULL) {
         $this->printer = new PHPUnit2_TextUI_ResultPrinter();
     }
     $this->printer->write(PHPUnit2_Runner_Version::getVersionString() . "\n\n");
     $result->addListener($this->printer);
     if ($testdoxHTMLFile !== FALSE || $testdoxTextFile !== FALSE) {
         require_once 'PHPUnit2/Util/TestDox/ResultPrinter.php';
         if ($testdoxHTMLFile !== FALSE) {
             $result->addListener(PHPUnit2_Util_TestDox_ResultPrinter::factory('HTML', $testdoxHTMLFile));
         }
         if ($testdoxTextFile !== FALSE) {
             $result->addListener(PHPUnit2_Util_TestDox_ResultPrinter::factory('Text', $testdoxTextFile));
         }
     }
     if ($xmlLogfile !== FALSE) {
         require_once 'PHPUnit2/Util/Log/XML.php';
         $result->addListener(new PHPUnit2_Util_Log_XML($xmlLogfile));
     }
     if ($coverageDataFile !== FALSE || $coverageHTMLFile !== FALSE || $coverageTextFile !== FALSE) {
         $result->collectCodeCoverageInformation(TRUE);
     }
     $timer->start();
     $suite->run($result);
     $timer->stop();
     $timeElapsed = $timer->timeElapsed();
     $this->pause($wait);
     $this->printer->printResult($result, $timeElapsed);
     $this->handleCodeCoverageInformation($result, $coverageDataFile, $coverageHTMLFile, $coverageTextFile);
     return $result;
 }