function it_applies_with_default_graph_and_default_transition($factory, TransitionEvent $event, DummyObject $object, StateMachineInterface $sm1, StateMachineInterface $sm2)
 {
     $event->getStateMachine()->willReturn($sm2);
     $event->getTransition()->willReturn('transition');
     $sm2->getGraph()->willReturn('graph');
     $factory->get($object, 'graph')->willReturn($sm1);
     $sm1->can('transition')->willReturn(true);
     $sm1->apply('transition', true)->shouldBeCalled();
     $this->apply($object, $event);
 }
 /**
  * Apply a transition to the object that has just undergone a transition
  *
  * @param \Traversable|array $objects    Object or array|traversable of objects to apply the transition on
  * @param TransitionEvent    $event      Transition event
  * @param string|null        $transition Transition that is to be applied (if null, same as the trigger)
  * @param string|null        $graph      Graph on which the new transition will apply (if null, same as the trigger)
  * @param bool               $soft       If true, check if it can apply the transition first (no Exception thrown)
  */
 public function apply($objects, TransitionEvent $event, $transition = null, $graph = null, $soft = true)
 {
     if (!is_array($objects) && !$objects instanceof \Traversable) {
         $objects = array($objects);
     }
     if (null === $transition) {
         $transition = $event->getTransition();
     }
     if (null === $graph) {
         $graph = $event->getStateMachine()->getGraph();
     }
     foreach ($objects as $object) {
         $this->factory->get($object, $graph)->apply($transition, $soft);
     }
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  */
 public function isSatisfiedBy(TransitionEvent $event)
 {
     $config = $event->getConfig();
     return $this->isSatisfiedByClause('on', $event->getTransition()) && $this->isSatisfiedByClause('from', $event->getState()) && $this->isSatisfiedByClause('to', $config['to']);
 }
Esempio n. 4
0
 function it_doesnt_satisfies_excluded_from(TransitionEvent $event)
 {
     $specs = array('to' => 'tested-state-to', 'excluded_from' => 'tested-state-from');
     $this->beConstructedWith($specs, $this->callable);
     $event->getConfig()->willReturn($this->getConfig(array('tested-state-from'), 'tested-state-to'));
     $event->getTransition()->willReturn('dummy');
     $event->getState()->willReturn('tested-state-from');
     $this->isSatisfiedBy($event)->shouldReturn(false);
 }