Command
Rasuvaeff\PropertyTesting\StateMachine\Command
Интерфейс — Исходник
Текст ниже — на английском, из PHPDoc в исходном коде.
A single operation in a stateful / model-based test.
A command bundles the four responsibilities of model-based testing: whether it may run in a given model state (preCondition()), how the model evolves (nextState()), how the real system executes it (run()), and how the observed result is checked against the model (postCondition()). Sequences of commands are generated by \Rasuvaeff\PropertyTesting\Gen::commands() and driven by StateMachine::check().
The model is an immutable value threaded through the sequence: nextState() must return the new model rather than mutate the given one, so the runner and the generator can replay it deterministically. preCondition(), nextState() and postCondition() must be pure — only run() touches the system under test.
Методы
preCondition()
preCondition(mixed $model): boolMay this command run in the given (pre-state) model? Gates both generation and, during replay, whether the runner executes or skips the command.
nextState()
nextState(mixed $model): mixedThe model's expected state after this command. Pure; returns the new model and never touches the system under test.
run()
run(mixed $model, mixed $system): mixedExecute this command against the system under test and return the observed result for postCondition() to check. The pre-state model is provided for commands whose action depends on it.
postCondition()
postCondition(mixed $model, mixed $result): boolVerify the observed result against the pre-state model. Return false (or throw) to falsify the property.