protected function setUp()
{
$this->env = new \Twig_Environment(
new \Twig_Loader_Array(
array(
'state' => '{{ finite_state(object) }}',
'transitions' => '{% for transition in finite_transitions(object) %}{{ transition }}{% endfor %}',
'properties' => '{% for property, val in finite_properties(object) %}{{ property }}{% endfor %}',
'has' => '{{ finite_has(object, property) ? "yes" : "no" }}',
'can' => '{{ finite_can(object, transition) ? "yes" : "no" }}'
)
)
);
$container = new \Pimple(array(
'state_machine' => function() {
$sm = new StateMachine;
$sm->addState(new State('s1', State::TYPE_INITIAL, array(), array('foo' => true, 'bar' => false)));
$sm->addTransition('t12', 's1', 's2');
$sm->addTransition('t23', 's2', 's3');
return $sm;
}
));
$this->context = new Context(new PimpleFactory($container, 'state_machine'));;
$this->env->addExtension(new FiniteExtension($this->context));
}