function let(StateMachineInterface $stateMachine) { $stateMachine->getGraph()->willReturn('checkout_state_machine'); $stateMachine->getPossibleTransitions()->willReturn(['start', 'abandon']); $this->beConstructedWith('start_checkout', $stateMachine); }
function let(StateMachineInterface $sm) { $sm->getState()->willReturn('checkout'); $this->beConstructedWith($this->specs, $this->callable); }
function it_provide_sm_getPossibleTransitions_function(FactoryInterface $factory, StateMachineInterface $stateMachine) { $this->getPossibleTransitions($object = new DummyObject(), 'simple'); $factory->get($object, 'simple')->shouldHaveBeenCalled(); $stateMachine->getPossibleTransitions()->shouldHaveBeenCalled(); }
/** * @param StateMachineInterface $stateMachine * @param string $transition */ private function applyTransition(StateMachineInterface $stateMachine, $transition) { if ($stateMachine->can($transition)) { $stateMachine->apply($transition); } }
/** * @param string $transition * @param StateMachineInterface $stateMachine */ public function __construct($transition, StateMachineInterface $stateMachine) { parent::__construct(sprintf('Transition "%s" is invalid for "%s" state machine. Possible transitions are: %s.', $transition, $stateMachine->getGraph(), implode($stateMachine->getPossibleTransitions(), ' and '))); }