Skip to content

CommandSequenceArbitrary

Rasuvaeff\PropertyTesting\Arbitrary\CommandSequenceArbitrary

ClassPackage: property-testing-coreSourceVersion: v0.1.0-12-g86ead85

Implements: ArbitraryInterface

Generates valid Command sequences for stateful / model-based testing and shrinks them by dropping and simplifying steps.

Generation is model-aware: at each step a command generator is drawn at random, and the produced command is appended only if its StateMachine\Command::preCondition() holds in the running model, which is then advanced via StateMachine\Command::nextState(). The sequence is therefore valid by construction; if no applicable command is found within a bounded number of attempts the sequence stops early.

Shrinking removes whole blocks of commands (most aggressive first, down to a single command so a failing step in the middle can be isolated) and then simplifies individual commands through their own shrink trees. Dropped or simplified sequences are not re-validated here — StateMachine\StateMachine::check() skips any command whose precondition a change invalidated, keeping every candidate sound.

Constructor

php
__construct(
    mixed $initialModel,
    array<array-key,\ArbitraryInterface> $commandGenerators,
    int $minLength = 0,
    int $maxLength = 100,
)
ParameterTypeDefaultDescription
$initialModelmixedrequired
$commandGeneratorsarray<array-key,\ArbitraryInterface>requiredEach must produce a StateMachine\Command.
$minLengthint0
$maxLengthint100

Methods

generate()

php
generate(Random $random): Shrinkable

Produce one random value from this arbitrary's space, together with its shrink tree. Candidates must be ordered most aggressive first (typically toward a zero/empty/identity element) and every branch of the tree must be finite, so shrinking terminates.

Documentation inherited from ArbitraryInterface.