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
directory()
public function directory(string $directory): self
maxAttachmentsPerTest()
public function maxAttachmentsPerTest(int $count): self
maxAttachmentSize()
public function maxAttachmentSize(string $size): self
maxTestSize()
public function maxTestSize(string $size): self
maxRunAttachments()
public function maxRunAttachments(int $count): self
maxRunSize()
public function maxRunSize(string $size): self
CoverageBuilder
Namespace: Greenlight\Config
Configures coverage collection and exports.
final class CoverageBuilder
include()
public function include(string ...$paths): self
PHPDoc:
@throws InvalidConfiguration
driver()
public function driver(string $driver): self
PHPDoc:
@throws InvalidConfiguration
export()
public function export(string $format, string $target): self
PHPDoc:
@throws InvalidConfiguration
GreenlightConfig
Namespace: Greenlight\Config
Collects the configuration that greenlight.php returns.
final class GreenlightConfig
create()
public static function create(): self
paths()
Sets the test-discovery directories for runs without a selected suite.
public function paths(array $tests): self
PHPDoc:
@param list<string> $tests@throws InvalidConfiguration
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:
@param callable(SuiteBuilder): mixed $configurator@throws InvalidConfiguration
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:
@param int|'auto' $count@param int|null $recycleAfterTests A null value disables test-count worker replacement.@throws InvalidConfiguration
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:
@throws InvalidConfiguration
coverage()
public function coverage(callable $configurator): self
PHPDoc:
@param callable(CoverageBuilder): mixed $configurator
watch()
public function watch(callable $configurator): self
PHPDoc:
@param callable(WatchBuilder): mixed $configurator
artifacts()
public function artifacts(callable $configurator): self
PHPDoc:
@param callable(ArtifactBuilder): mixed $configurator
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:
@see self::ignoreDeprecationsMatching()
failOnNotice()
public function failOnNotice(bool $enabled = true): self
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
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
plugins()
public function plugins(Plugin ...$plugins): self
failFast()
public function failFast(bool $enabled = true): self
randomizeOrder()
If the seed is null, Greenlight generates and prints a seed at run time.
public function randomizeOrder(?int $seed = null): self
build()
public function build(): Configuration
PHPDoc:
@throws InvalidConfiguration
SuiteBuilder
Namespace: Greenlight\Config
Configures a named suite.
final class SuiteBuilder
in()
public function in(string ...$paths): self
PHPDoc:
@throws InvalidConfiguration
tag()
public function tag(string ...$tags): self
PHPDoc:
@throws InvalidConfiguration
WatchBuilder
Namespace: Greenlight\Config
final class WatchBuilder
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:
@throws InvalidConfiguration