Browse documentation

Fixtures and harness API

This reference lists fixtures and harness service contracts.

These signatures are the public API.

EnvironmentSandbox

Namespace: Greenlight\Fixture

Updates getenv(), $_ENV, and $_SERVER together. It records each original value one time and restores the value during disposal.

final class EnvironmentSandbox implements Disposable

View source

set()

public function set(string $name, string $value): void

PHPDoc:

View source

unset()

public function unset(string $name): void

PHPDoc:

View source

dispose()

[\Override]
public function dispose(): void

View source

TempDirectory

Namespace: Greenlight\Fixture

Creates one root directory on first use. A path inside it cannot escape the root. Disposal removes a symbolic link and leaves its target unchanged.

final class TempDirectory implements Disposable

View source

path()

public function path(): string

View source

subdirectory()

public function subdirectory(string $name): string

PHPDoc:

View source

dispose()

[\Override]
public function dispose(): void

View source

Disposable

Namespace: Greenlight\Harness

A harness service that Greenlight disposes when its service scope closes.

Greenlight disposes services in reverse creation order. An exception from one service does not prevent disposal of the remaining services.

interface Disposable

View source

dispose()

public function dispose(): void;

View source

Scope

Namespace: Greenlight\Harness

Defines the lifetime of a harness service.

PerRun matches the worker lifetime.

enum Scope: string

View source

PerTest

case PerTest = 'per-test';

View source

PerClass

case PerClass = 'per-class';

View source

PerSuite

case PerSuite = 'per-suite';

View source

PerRun

case PerRun = 'per-run';

View source

ServiceDefinition

Namespace: Greenlight\Harness

Defines one harness service. It contains the exact injected type, service scope, and factory.

final readonly class ServiceDefinition

View source

$type

public string $type;

PHPDoc:

View source

__construct()

public function __construct(
    string $type,
    public Scope $scope,
    public \Closure $factory,
)

PHPDoc:

View source

ServiceResolver

Namespace: Greenlight\Harness

Greenlight calls service resolvers in registration order. If a resolver returns null, Greenlight calls the next resolver. A nonnull result must have the requested type.

Objects from a service resolver do not belong to a harness service scope. Greenlight does not dispose them. The source of an object controls its lifetime.

interface ServiceResolver

View source

resolve()

public function resolve(string $type, array $attributes): ?object;

PHPDoc:

View source