public setStateAccessor ( Finite\State\Accessor\StateAccessorInterface $stateAccessor ) | ||
$stateAccessor | Finite\State\Accessor\StateAccessorInterface |
/** * @param NULL|mixed $state scalar */ public function __construct($state = NULL) { $this->stateMachine = new StateMachine($this); $this->getLoader()->load($this->stateMachine); // intentionally set after ArrayLoader::load, as it sets symfony accessor $this->stateMachine->setStateAccessor(new StatefulPropertyStateAccessor()); $this->stateMachine->initialize(); $this->setFiniteState($state ?: $this->getInitialState()); $this->onModify(); }
public function testLoadWithCustomStateAccessor() { $sa = $this->getMock('Finite\\State\\Accessor\\PropertyPathStateAccessor', array(), array(), 'CustomAccessor'); $sm = new StateMachine(); $sm->setStateAccessor($sa); $this->object->load($sm); $this->assertAttributeInstanceOf('CustomAccessor', 'stateAccessor', $sm); }