Skip to content

Examples

Every package ships its own examples/, runnable after composer install via the composer:2 Docker image (no PHP/Composer needed on the host).

property-testing-core

ScriptShowsNeeds server?
basic.phpA property that holds, one that is falsified, and how the counterexample is shrunk by descending the Shrinkable tree (uses generators directly, no runner)No
generators.phpsample, boundary bias, uuid, datetime, dictOf, record, and dependent generation with flatMap (uses generators directly, no runner)No
standalone_runner.phpDriving the framework-agnostic engine directly: a hand-built PropertyDefinition, CallableTrialExecutor, and structured PropertyResult inspectionNo
custom_listeners.phpCustom observers over the engine's event model: a console reporter narrating the shrink descent and a telemetry collector aggregating run counts, timings and labels — pure PropertyListener implementations, no engine changesNo
case-studies/regex-anchor.phpCookbook case study: a $-anchored identifier validator accepting a trailing newlineNo
case-studies/saturating-minus.phpCookbook case study: subtraction producing a negative duration instead of saturating at zeroNo
case-studies/backoff-cap.phpCookbook case study: jitter added after the cap was applied, pushing the delay past itNo
case-studies/hash-bucketing.phpCookbook case study: a rollout hash salted with the percentage, breaking monotonicityNo

property-testing-testo

ScriptShowsNeeds server?
property_test.phpCanonical #[Property] usage as a real Testo test case, including an in-body dependent draw with Gen::draw()No
state_machine.phpStateful / model-based testing: a Command interface, Gen::commands(), and StateMachine::check() driving command sequences against a stackNo

property-testing-phpunit

ExampleShowsNeeds server?
SortPropertyTest.phpA complete property-based PHPUnit TestCase: the PropertyTesting trait, the fluent forAll()->runs()->check() chain, Classify::when() distribution labels, and an Assume::that() discard — three properties over a plain sortNo