Result API
This reference lists test outcomes, diagnostics, failure details, and result values.
These signatures are the public API.
CapturedOutput
Namespace: Greenlight\Core\Result
When output is too long, Greenlight keeps the first part. This part usually identifies the cause. The last part usually contains repeated information.
Greenlight converts standard output to valid UTF-8 before it crosses the wire.
final readonly class CapturedOutput implements WireSerializable
$diagnostics
public array $diagnostics;
PHPDoc:
@var list<Diagnostic>
__construct()
public function __construct(
public string $stdout,
array $diagnostics = [],
public bool $stdoutTruncated = false,
public bool $diagnosticsTruncated = false,
)
PHPDoc:
@param array<mixed> $diagnostics@throws \InvalidArgumentException
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
Diagnostic
Namespace: Greenlight\Core\Result
Greenlight converts the message and file to valid UTF-8 before the diagnostic crosses the wire. These values originate in user code. The line number MUST be greater than zero.
final readonly class Diagnostic implements WireSerializable
$line
public int $line;
PHPDoc:
@var positive-int
__construct()
public function __construct(
public DiagnosticSeverity $severity,
public string $message,
public string $file,
int $line,
)
PHPDoc:
@throws \InvalidArgumentException
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
DiagnosticSeverity
Namespace: Greenlight\Core\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\Core\Result
Expected and actual are strings that the worker renders. Live values never cross the process boundary.
final readonly class FailureDetail implements WireSerializable
$message
public string $message;
PHPDoc:
@var non-empty-string
__construct()
public function __construct(
string $message,
public ?string $expected = null,
public ?string $actual = null,
public ?SourceLocation $location = null,
)
PHPDoc:
@throws \InvalidArgumentException
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
Outcome
Namespace: Greenlight\Core\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\Core\Result
Records the source of a plugin change to a test outcome.
final readonly class OutcomeTransformation implements WireSerializable
$transformedBy
public string $transformedBy;
PHPDoc:
@var non-empty-string
__construct()
public function __construct(
string $transformedBy,
public Outcome $from,
public Outcome $to,
)
PHPDoc:
@throws \InvalidArgumentException
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
ResultSummary
Namespace: Greenlight\Core\Result
Aggregate outcome counts for a run.
final readonly class ResultSummary implements WireSerializable
$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
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
SourceLocation
Namespace: Greenlight\Core\Result
final readonly class SourceLocation implements WireSerializable, \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()
[\Override]
public function __toString(): string
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
TestResult
Namespace: Greenlight\Core\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 matcher in a chain separately. It counts each mock expectation when disposal verifies it. Stubs do not add to the count. An unsuccessful result contains the count at the time of the abort. Old wire payloads without this field decode to zero.
final readonly class TestResult implements WireSerializable
$attempts
public int $attempts;
PHPDoc:
@var positive-int
$expectations
public int $expectations;
PHPDoc:
@var non-negative-int
__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
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static
ThrowableDetail
Namespace: Greenlight\Core\Result
Limits stack frames so a deep trace cannot make the wire payload too large.
final readonly class ThrowableDetail implements WireSerializable
$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
__construct()
public function __construct(
string $class,
public string $message,
string $file,
int $line,
public array $stackFrames = [],
)
PHPDoc:
@param list<string> $stackFrames@throws \InvalidArgumentException
fromThrowable()
public static function fromThrowable(\Throwable $throwable): self
toWire()
[\Override]
public function toWire(): array
fromWire()
[\Override]
public static function fromWire(array $payload): static