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
| Script | Shows | Needs server? |
|---|---|---|
basic.php | A 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.php | sample, boundary bias, uuid, datetime, dictOf, record, and dependent generation with flatMap (uses generators directly, no runner) | No |
standalone_runner.php | Driving the framework-agnostic engine directly: a hand-built PropertyDefinition, CallableTrialExecutor, and structured PropertyResult inspection | No |
custom_listeners.php | Custom 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 changes | No |
case-studies/regex-anchor.php | Cookbook case study: a $-anchored identifier validator accepting a trailing newline | No |
case-studies/saturating-minus.php | Cookbook case study: subtraction producing a negative duration instead of saturating at zero | No |
case-studies/backoff-cap.php | Cookbook case study: jitter added after the cap was applied, pushing the delay past it | No |
case-studies/hash-bucketing.php | Cookbook case study: a rollout hash salted with the percentage, breaking monotonicity | No |
property-testing-testo
| Script | Shows | Needs server? |
|---|---|---|
property_test.php | Canonical #[Property] usage as a real Testo test case, including an in-body dependent draw with Gen::draw() | No |
state_machine.php | Stateful / model-based testing: a Command interface, Gen::commands(), and StateMachine::check() driving command sequences against a stack | No |
property-testing-phpunit
| Example | Shows | Needs server? |
|---|---|---|
SortPropertyTest.php | A 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 sort | No |