Skip to content

PropertyCheck

Rasuvaeff\PropertyTesting\PhpUnit\PropertyCheck

ClassPackage: property-testing-phpunitSourceVersion: v0.1.0

Fluent builder mapping the engine's structured PropertyResult onto PHPUnit: a pass counts one assertion, every failing outcome surfaces as one AssertionFailedError carrying the engine failure as previous — the message is the engine's own (seed, original and shrunk arguments, shrink statistics included).

Environment parity with the Testo adapter: PROPERTY_RUNS overrides every run count, PROPERTY_SEED seeds unseeded properties (an explicit PhpUnit\seed() wins), PROPERTY_VERBOSE traces every run, and PROPERTY_DB enables the regression corpus — an explicit seed() disables replay, exactly like an attribute seed does under Testo. An Assume::that() discard is a discarded run inside the property, never a skipped PHPUnit test.

Constructor

php
__construct(
    PHPUnit\Framework\TestCase $testCase,
    string $id,
    string $name,
    array<string,\ArbitraryInterface> $generators,
)
ParameterTypeDefaultDescription
$testCasePHPUnit\Framework\TestCaserequired
$idstringrequired
$namestringrequired
$generatorsarray<string,\ArbitraryInterface>required

Methods

runs()

php
runs(int $runs): self

Number of successful checks to complete; discarded runs do not count.

seed()

php
seed(int $seed): self

Pins the random phase's seed. A pinned seed also disables regression replay, so the pinned reproducibility wins over the corpus.

maxShrinks()

php
maxShrinks(int $maxShrinks): self

Cap on accepted shrink steps; 0 disables shrinking.

maxDiscards()

php
maxDiscards(int $maxDiscards): self

Maximum discarded runs before the property gives up.

timeoutMs()

php
timeoutMs(int $timeoutMs): self

Wall-clock deadline for a single run, in milliseconds.

budgetMs()

php
budgetMs(int $budgetMs): self

Wall-clock budget for the whole random phase, in milliseconds.

examples()

php
examples(list<list> $examples): self

Fixed positional argument tuples run before the random phase. A failing example short-circuits and is reported unshrunk — it is already minimal.

listeners()

php
listeners(PropertyListener $listeners): self

Observers of the run's engine events, notified in the given order.

output()

php
output(resource $stdout, resource $stderr): self

Redirects the distribution report, discard warning and verbose trace — for tests of this adapter itself.

check()

php
check(callable $property): void

Runs the property. The closure's parameter names select the generators.