/**
  * Returns "..." in place of common prefix and "..." in
  * place of common suffix between expected and actual.
  *
  * @return string
  * @access public
  */
 public function toString()
 {
     $end = min(strlen($this->expected), strlen($this->actual));
     $i = 0;
     $j = strlen($this->expected) - 1;
     $k = strlen($this->actual) - 1;
     for (; $i < $end; $i++) {
         if ($this->expected[$i] != $this->actual[$i]) {
             break;
         }
     }
     for (; $k >= $i && $j >= $i; $k--, $j--) {
         if ($this->expected[$j] != $this->actual[$k]) {
             break;
         }
     }
     if ($j < $i && $k < $i) {
         $expected = $this->expected;
         $actual = $this->actual;
     } else {
         $expected = substr($this->expected, $i, $j + 1 - $i);
         $actual = substr($this->actual, $i, $k + 1 - $i);
         if ($i <= $end && $i > 0) {
             $expected = '...' . $expected;
             $actual = '...' . $actual;
         }
         if ($j < strlen($this->expected) - 1) {
             $expected .= '...';
         }
         if ($k < strlen($this->actual) - 1) {
             $actual .= '...';
         }
     }
     return PHPUnit2_Framework_Assert::format($expected, $actual, parent::getMessage());
 }
Ejemplo n.º 2
0
 /**
  * Adds the failure detail to the current test and increases the failure
  * count for the current suite
  * 
  * @access public
  * @param obj PHPUnit2_Framework_Test, current test that is being run
  * @param obj PHPUnit2_Framework_AssertationFailedError, PHPUnit2 error
  * @return void
  */
 public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e)
 {
     $this->currentSuite['failures']++;
     $this->currentTest['status'] = TEST_FAILURE;
     $this->currentTest['message'] = $e->toString();
     $this->currentTest['exception'] = $this->getTestException($test, $e);
 }
Ejemplo n.º 3
0
 /**
  * A failure occurred.
  *
  * @param  PHPUnit2_Framework_Test                 $test
  * @param  PHPUnit2_Framework_AssertionFailedError $e
  * @access public
  */
 public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e)
 {
     $this->log->err(sprintf('Test "%s" failed: %s', $test->getName(), $e->getMessage()));
 }
Ejemplo n.º 4
0
 public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e)
 {
     $test->failed = true;
     echo '<td class="failure">Gefaald (' . htmlentities($e->getMessage()) . ')</td>';
 }