public function testItRetrievesGoodStateMachine() { $object = $this->getMock('Finite\\StatefulInterface'); $factory = $this->getMock('Finite\\Factory\\FactoryInterface'); $sm = $this->getMock('Finite\\StateMachine\\StateMachineInterface'); $factory->expects($this->once())->method('get')->with($object, 'foo')->will($this->returnValue($sm)); $context = new Context($factory); $this->assertSame($sm, $context->getStateMachine($object, 'foo')); }
/** * {@inheritDoc} */ public function apply(CartInterface $cart, $transition, $andFlush = false) { $finiteStateMachine = $this->finiteContext->getStateMachine($cart); if ($finiteStateMachine->can($transition)) { $finiteStateMachine->apply($transition); if ($andFlush) { $this->cartManager->updateCart($cart); } return true; } throw new TransitionException($transition, $cart->getState()); }
/** * @param object $object * @param string $transition * @param string $graph * * @return bool|mixed */ public function canFiniteTransition($object, $transition, $graph = 'default') { return $this->context->getStateMachine($object, $graph)->can($transition); }
public function testHasProperty() { $this->assertTrue($this->object->hasProperty($this->getObjectMock(), 'foo')); $this->assertFalse($this->object->hasProperty($this->getObjectMock(), 'baz')); }
/** * @param StatefulInterface $object * @param $transition * * @return bool|mixed */ public function canFiniteTransition(StatefulInterface $object, $transition) { return $this->context->getStateMachine($object)->can($transition); }