Browse documentation

Configuration API

This reference lists the builders that configure Greenlight runs.

These signatures are the public API.

ArtifactBuilder

Namespace: Greenlight\Config

Collects the configuration for attachment output and safety limits.

final class ArtifactBuilder

View source

directory()

public function directory(string $directory): self

View source

maxAttachmentsPerTest()

public function maxAttachmentsPerTest(int $count): self

View source

maxAttachmentSize()

public function maxAttachmentSize(string $size): self

View source

maxTestSize()

public function maxTestSize(string $size): self

View source

maxRunAttachments()

public function maxRunAttachments(int $count): self

View source

maxRunSize()

public function maxRunSize(string $size): self

View source

CoverageBuilder

Namespace: Greenlight\Config

Configures coverage collection and exports.

final class CoverageBuilder

View source

include()

public function include(string ...$paths): self

PHPDoc:

View source

driver()

public function driver(string $driver): self

PHPDoc:

View source

export()

public function export(string $format, string $target): self

PHPDoc:

View source

GreenlightConfig

Namespace: Greenlight\Config

Collects the configuration that greenlight.php returns.

final class GreenlightConfig

View source

create()

public static function create(): self

View source

paths()

Sets the test-discovery directories for runs without a selected suite.

public function paths(array $tests): self

PHPDoc:

View source

suite()

Declares a named suite. The configurator receives a SuiteBuilder. The configurator must add at least one path with in(). Greenlight ignores the return value, which permits short arrow functions.

public function suite(string $name, callable $configurator): self

PHPDoc:

View source

workers()

Greenlight replaces a worker after the specified number of tests only when $recycleAfterTests has a value. Use this option for state that the memory limit cannot control.

public function workers(
    int|string $count = 'auto',
    ?int $recycleAfterTests = null,
    string $recycleAboveMemory = self::DEFAULT_RECYCLE_ABOVE_MEMORY,
): self

PHPDoc:

View source

resourceLimit()

Sets the maximum number of concurrent assignments that require the named resource.

A resource without an explicit resource limit has a limit of one.

public function resourceLimit(string $name, int $limit = 1): self

PHPDoc:

View source

coverage()

public function coverage(callable $configurator): self

PHPDoc:

View source

watch()

public function watch(callable $configurator): self

PHPDoc:

View source

artifacts()

public function artifacts(callable $configurator): self

PHPDoc:

View source

failOnDeprecation()

Fails an otherwise passed test if captured output contains a deprecation. The diagnostic becomes the failure detail. Use a regular expression to exempt known dependency messages.

public function failOnDeprecation(bool $enabled = true): self

PHPDoc:

View source

failOnNotice()

public function failOnNotice(bool $enabled = true): self

View source

failOnRisky()

Fails an otherwise passed test if the test verifies no expectations. Use #[NoExpectations] to exempt a test that intentionally verifies no expectations.

public function failOnRisky(bool $enabled = true): self

View source

ignoreDeprecationsMatching()

Exempts deprecation messages from failOnDeprecation(). A pattern matches part of a message without case sensitivity. A pattern that contains ”*” or ”?” matches the complete message. Multiple calls add patterns.

public function ignoreDeprecationsMatching(string ...$patterns): self

View source

plugins()

public function plugins(Plugin ...$plugins): self

View source

failFast()

public function failFast(bool $enabled = true): self

View source

randomizeOrder()

If the seed is null, Greenlight generates and prints a seed at run time.

public function randomizeOrder(?int $seed = null): self

View source

build()

public function build(): Configuration

PHPDoc:

View source

SuiteBuilder

Namespace: Greenlight\Config

Configures a named suite.

final class SuiteBuilder

View source

in()

public function in(string ...$paths): self

PHPDoc:

View source

tag()

public function tag(string ...$tags): self

PHPDoc:

View source

WatchBuilder

Namespace: Greenlight\Config

final class WatchBuilder

View source

debounceMilliseconds()

Sets the quiet period before a new run. The period restarts after each change. Thus, multiple consecutive saves cause one run.

public function debounceMilliseconds(int $milliseconds): self

PHPDoc:

View source