class Failed
@psalm-immutable
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\Event\Test\Failed implements \PHPUnit\Event\Event
Expanded class hierarchy of Failed
12 files declare their use of Failed
- Collector.php in vendor/
phpunit/ phpunit/ src/ Runner/ TestResult/ Collector.php - JunitXmlLogger.php in vendor/
phpunit/ phpunit/ src/ Logging/ JUnit/ JunitXmlLogger.php - ResultCacheHandler.php in vendor/
phpunit/ phpunit/ src/ Runner/ ResultCache/ ResultCacheHandler.php - TeamCityLogger.php in vendor/
phpunit/ phpunit/ src/ Logging/ TeamCity/ TeamCityLogger.php - TestFailedSubscriber.php in vendor/
phpunit/ phpunit/ src/ TextUI/ Output/ Default/ ProgressPrinter/ Subscriber/ TestFailedSubscriber.php
File
-
vendor/
phpunit/ phpunit/ src/ Event/ Events/ Test/ Outcome/ Failed.php, line 26
Namespace
PHPUnit\Event\TestView source
final class Failed implements Event {
private readonly Telemetry\Info $telemetryInfo;
private readonly Code\Test $test;
private readonly Throwable $throwable;
private readonly ?ComparisonFailure $comparisonFailure;
public function __construct(Telemetry\Info $telemetryInfo, Code\Test $test, Throwable $throwable, ?ComparisonFailure $comparisonFailure) {
$this->telemetryInfo = $telemetryInfo;
$this->test = $test;
$this->throwable = $throwable;
$this->comparisonFailure = $comparisonFailure;
}
public function telemetryInfo() : Telemetry\Info {
return $this->telemetryInfo;
}
public function test() : Code\Test {
return $this->test;
}
public function throwable() : Throwable {
return $this->throwable;
}
/**
* @psalm-assert-if-true !null $this->comparisonFailure
*/
public function hasComparisonFailure() : bool {
return $this->comparisonFailure !== null;
}
/**
* @throws NoComparisonFailureException
*/
public function comparisonFailure() : ComparisonFailure {
if ($this->comparisonFailure === null) {
throw new NoComparisonFailureException();
}
return $this->comparisonFailure;
}
public function asString() : string {
$message = trim($this->throwable
->message());
if (!empty($message)) {
$message = PHP_EOL . $message;
}
return sprintf('Test Failed (%s)%s', $this->test
->id(), $message);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
Failed::$comparisonFailure | private | property | ||
Failed::$telemetryInfo | private | property | ||
Failed::$test | private | property | ||
Failed::$throwable | private | property | ||
Failed::asString | public | function | Overrides Event::asString | |
Failed::comparisonFailure | public | function | ||
Failed::hasComparisonFailure | public | function | @psalm-assert-if-true !null $this->comparisonFailure | |
Failed::telemetryInfo | public | function | Overrides Event::telemetryInfo | |
Failed::test | public | function | ||
Failed::throwable | public | function | ||
Failed::__construct | public | function |