Result API
This reference lists test outcomes, diagnostics, failure details, and result values.
These signatures are the public API.
CapturedOutput
Namespace: Greenlight\Result
Contains standard output, diagnostics, and truncation flags for one attempt. When output exceeds the capture limit, Greenlight keeps the first part.
Greenlight converts captured standard output to valid UTF-8 before it adds the output to a test result.
final readonly class CapturedOutput
$diagnostics
public array $diagnostics;
PHPDoc:
@var list<Diagnostic>
$stdout
public string $stdout
$stdoutTruncated
public bool $stdoutTruncated
$diagnosticsTruncated
public bool $diagnosticsTruncated
__construct()
public function __construct(
public string $stdout,
array $diagnostics = [],
public bool $stdoutTruncated = false,
public bool $diagnosticsTruncated = false,
)
PHPDoc:
@param array<mixed> $diagnostics@throws \InvalidArgumentException
Diagnostic
Namespace: Greenlight\Result
Greenlight converts the message and file to valid UTF-8 before it adds the diagnostic to a test result. These values originate in user code. The line number is greater than zero.
final readonly class Diagnostic
$line
public int $line;
PHPDoc:
@var positive-int
$severity
public DiagnosticSeverity $severity
$message
public string $message
$file
public string $file
__construct()
public function __construct(
public DiagnosticSeverity $severity,
public string $message,
public string $file,
int $line,
)
PHPDoc:
@throws \InvalidArgumentException
DiagnosticSeverity
Namespace: Greenlight\Result
Greenlight captures only notices, warnings, and deprecations. PHP uses its default behavior for all other error levels.
enum DiagnosticSeverity: string
Notice
case Notice = 'notice';
Warning
case Warning = 'warning';
Deprecation
case Deprecation = 'deprecation';
fromErrorLevel()
Maps an engine error level to a diagnostic severity.
Returns null if Greenlight cannot capture the diagnostic.
public static function fromErrorLevel(int $level): ?self
FailureDetail
Namespace: Greenlight\Result
Expected and actual are strings that the worker renders. Live values never cross the process boundary.
final readonly class FailureDetail
$message
public string $message;
PHPDoc:
@var non-empty-string
$expected
public ?string $expected
$actual
public ?string $actual
$location
public ?SourceLocation $location
__construct()
public function __construct(
string $message,
public ?string $expected = null,
public ?string $actual = null,
public ?SourceLocation $location = null,
)
PHPDoc:
@throws \InvalidArgumentException
Outcome
Namespace: Greenlight\Result
A retried test has exactly one of these final outcomes. TestResult contains
the attempt count.
enum Outcome: string
Passed
case Passed = 'passed';
Failed
case Failed = 'failed';
Errored
case Errored = 'errored';
Skipped
case Skipped = 'skipped';
isSuccessful()
public function isSuccessful(): bool
OutcomeTransformation
Namespace: Greenlight\Result
Records the source of a plugin change to a test outcome.
final readonly class OutcomeTransformation
$transformedBy
public string $transformedBy;
PHPDoc:
@var non-empty-string
$from
public Outcome $from
$to
public Outcome $to
__construct()
public function __construct(
string $transformedBy,
public Outcome $from,
public Outcome $to,
)
PHPDoc:
@throws \InvalidArgumentException
ResultSummary
Namespace: Greenlight\Result
Aggregate outcome counts for a run.
final readonly class ResultSummary
$passed
public int $passed;
PHPDoc:
@var non-negative-int
$failed
public int $failed;
PHPDoc:
@var non-negative-int
$errored
public int $errored;
PHPDoc:
@var non-negative-int
$skipped
public int $skipped;
PHPDoc:
@var non-negative-int
__construct()
public function __construct(
int $passed = 0,
int $failed = 0,
int $errored = 0,
int $skipped = 0,
)
PHPDoc:
@throws \InvalidArgumentException
add()
public function add(Outcome $outcome): self
total()
public function total(): int
PHPDoc:
@return non-negative-int
isSuccessful()
public function isSuccessful(): bool
SourceLocation
Namespace: Greenlight\Result
final readonly class SourceLocation implements \Stringable
$file
public string $file;
PHPDoc:
@var non-empty-string
$line
public int $line;
PHPDoc:
@var positive-int
__construct()
public function __construct(string $file, int $line)
PHPDoc:
@throws \InvalidArgumentException
__toString()
public function __toString(): string
TestResult
Namespace: Greenlight\Result
A plugin does not change a result object. It uses withOutcome() to produce
a replacement and record the source of the change.
The expectations value counts each immediate matcher and each mock expectation that disposal verifies. Each temporal matcher counts once, regardless of the number of polls. Stubs do not add to the count.
The worker records the count after cleanup and per-test service disposal,
before afterTest() subscribers. Retries report the final attempt’s count.
final readonly class TestResult
$attempts
public int $attempts;
PHPDoc:
@var positive-int
$expectations
public int $expectations;
PHPDoc:
@var non-negative-int
$id
public TestId $id
$outcome
public Outcome $outcome
$durationSeconds
public float $durationSeconds
$memoryDeltaBytes
public int $memoryDeltaBytes
$failures
public array $failures
$error
public ?ThrowableDetail $error
$skipReason
public ?string $skipReason
$transformations
public array $transformations
$output
public ?CapturedOutput $output
$risky
public bool $risky
$attachments
public array $attachments
__construct()
public function __construct(
public TestId $id,
public Outcome $outcome,
public float $durationSeconds,
public int $memoryDeltaBytes,
int $attempts = 1,
public array $failures = [],
public ?ThrowableDetail $error = null,
public ?string $skipReason = null,
public array $transformations = [],
public ?CapturedOutput $output = null,
public bool $risky = false,
int $expectations = 0,
public array $attachments = [],
)
PHPDoc:
@param list<FailureDetail> $failures@param list<OutcomeTransformation> $transformations@param list<Attachment> $attachments@throws \InvalidArgumentException
withOutcome()
public function withOutcome(Outcome $outcome, string $transformedBy): self
PHPDoc:
@param non-empty-string $transformedBy@throws \InvalidArgumentException if the transformation source is empty
ThrowableDetail
Namespace: Greenlight\Result
Contains a throwable’s class, message, source location, and stack trace.
final readonly class ThrowableDetail
$class
public string $class;
PHPDoc:
@var non-empty-string
$file
public string $file;
PHPDoc:
@var non-empty-string
$line
public int $line;
PHPDoc:
@var positive-int
$message
public string $message
$stackFrames
public array $stackFrames
__construct()
public function __construct(
string $class,
public string $message,
string $file,
int $line,
public array $stackFrames = [],
)
PHPDoc:
@param list<string> $stackFrames@throws \InvalidArgumentException
fromThrowable()
Records at most 32 stack frames. Adds a truncation marker if more frames exist.
public static function fromThrowable(\Throwable $throwable): self