PHPUnit_Framework_TestResult::addFailure PHP Метод

addFailure() публичный Метод

The passed in exception caused the failure.
public addFailure ( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, float $time )
$test PHPUnit_Framework_Test
$e PHPUnit_Framework_AssertionFailedError
$time float
    public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
    {
        if ($e instanceof PHPUnit_Framework_RiskyTest || $e instanceof PHPUnit_Framework_OutputError) {
            $this->risky[] = new PHPUnit_Framework_TestFailure($test, $e);
            $notifyMethod = 'addRiskyTest';
            if ($this->stopOnRisky) {
                $this->stop();
            }
        } elseif ($e instanceof PHPUnit_Framework_IncompleteTest) {
            $this->notImplemented[] = new PHPUnit_Framework_TestFailure($test, $e);
            $notifyMethod = 'addIncompleteTest';
            if ($this->stopOnIncomplete) {
                $this->stop();
            }
        } elseif ($e instanceof PHPUnit_Framework_SkippedTest) {
            $this->skipped[] = new PHPUnit_Framework_TestFailure($test, $e);
            $notifyMethod = 'addSkippedTest';
            if ($this->stopOnSkipped) {
                $this->stop();
            }
        } else {
            $this->failures[] = new PHPUnit_Framework_TestFailure($test, $e);
            $notifyMethod = 'addFailure';
            if ($this->stopOnFailure) {
                $this->stop();
            }
        }
        foreach ($this->listeners as $listener) {
            $listener->{$notifyMethod}($test, $e, $time);
        }
        $this->lastTestFailed = true;
        $this->time += $time;
    }

Usage Example

Пример #1
0
 public function runStep(Step $step)
 {
     $result = null;
     $this->fire(Events::STEP_BEFORE, new StepEvent($this, $step));
     try {
         $result = $step->run($this->moduleContainer);
     } catch (ConditionalAssertionFailed $f) {
         $this->testResult->addFailure(clone $this, $f, $this->testResult->time());
     } catch (\Exception $e) {
         $this->fire(Events::STEP_AFTER, new StepEvent($this, $step));
         throw $e;
     }
     $this->fire(Events::STEP_AFTER, new StepEvent($this, $step));
     return $result;
 }
All Usage Examples Of PHPUnit_Framework_TestResult::addFailure