Browse documentation

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

View source

$diagnostics

public array $diagnostics;

PHPDoc:

View source

__construct()

public function __construct(
    public string $stdout,
    array $diagnostics = [],
    public bool $stdoutTruncated = false,
    public bool $diagnosticsTruncated = false,
)

PHPDoc:

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

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

View source

$line

public int $line;

PHPDoc:

View source

__construct()

public function __construct(
    public DiagnosticSeverity $severity,
    public string $message,
    public string $file,
    int $line,
)

PHPDoc:

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

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

View source

Notice

case Notice = 'notice';

View source

Warning

case Warning = 'warning';

View source

Deprecation

case Deprecation = 'deprecation';

View source

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

View source

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

View source

$message

public string $message;

PHPDoc:

View source

__construct()

public function __construct(
    string $message,
    public ?string $expected = null,
    public ?string $actual = null,
    public ?SourceLocation $location = null,
)

PHPDoc:

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

Outcome

Namespace: Greenlight\Core\Result

A retried test has exactly one of these final outcomes. TestResult contains the attempt count.

enum Outcome: string

View source

Passed

case Passed = 'passed';

View source

Failed

case Failed = 'failed';

View source

Errored

case Errored = 'errored';

View source

Skipped

case Skipped = 'skipped';

View source

isSuccessful()

public function isSuccessful(): bool

View source

OutcomeTransformation

Namespace: Greenlight\Core\Result

Records the source of a plugin change to a test outcome.

final readonly class OutcomeTransformation implements WireSerializable

View source

$transformedBy

public string $transformedBy;

PHPDoc:

View source

__construct()

public function __construct(
    string $transformedBy,
    public Outcome $from,
    public Outcome $to,
)

PHPDoc:

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

ResultSummary

Namespace: Greenlight\Core\Result

Aggregate outcome counts for a run.

final readonly class ResultSummary implements WireSerializable

View source

$passed

public int $passed;

PHPDoc:

View source

$failed

public int $failed;

PHPDoc:

View source

$errored

public int $errored;

PHPDoc:

View source

$skipped

public int $skipped;

PHPDoc:

View source

__construct()

public function __construct(
    int $passed = 0,
    int $failed = 0,
    int $errored = 0,
    int $skipped = 0,
)

PHPDoc:

View source

add()

public function add(Outcome $outcome): self

View source

total()

public function total(): int

PHPDoc:

View source

isSuccessful()

public function isSuccessful(): bool

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

SourceLocation

Namespace: Greenlight\Core\Result

final readonly class SourceLocation implements WireSerializable, \Stringable

View source

$file

public string $file;

PHPDoc:

View source

$line

public int $line;

PHPDoc:

View source

__construct()

public function __construct(string $file, int $line)

PHPDoc:

View source

__toString()

[\Override]
public function __toString(): string

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

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

View source

$attempts

public int $attempts;

PHPDoc:

View source

$expectations

public int $expectations;

PHPDoc:

View source

__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:

View source

withOutcome()

public function withOutcome(Outcome $outcome, string $transformedBy): self

PHPDoc:

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source

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

View source

$class

public string $class;

PHPDoc:

View source

$file

public string $file;

PHPDoc:

View source

$line

public int $line;

PHPDoc:

View source

__construct()

public function __construct(
    string $class,
    public string $message,
    string $file,
    int $line,
    public array $stackFrames = [],
)

PHPDoc:

View source

fromThrowable()

public static function fromThrowable(\Throwable $throwable): self

View source

toWire()

[\Override]
public function toWire(): array

View source

fromWire()

[\Override]
public static function fromWire(array $payload): static

View source