public function testTransitionCached()
 {
     $this->src->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => ['A' => ['transition' => ['B' => []]], 'B' => []]]);
     $tr = $this->src->getTransitions('wid/A', null, null);
     reset($tr);
     //$startId = key($tr);
     $transition1 = current($tr);
     $tr = null;
     $tr = $this->src->getTransitions('wid/A', null, null);
     reset($tr);
     //$startId = key($tr);
     $transition2 = current($tr);
     $this->assertTrue(spl_object_hash($transition1) == spl_object_hash($transition2));
 }
 public function testLoadWorkflowSuccess2()
 {
     $factory = new ArrayWorkflowItemFactory();
     $factory->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => ['A' => ['label' => 'Entry', 'transition' => 'A,B'], 'B' => ['label' => 'Published', 'transition' => '  A  , B  ']]]);
     verify($factory->getStatus('wid/A', null, null))->notNull();
     verify($factory->getStatus('wid/B', null, null))->notNull();
     verify(count($factory->getTransitions('wid/A', null, null)))->equals(2);
 }
 public function testFailToLoadWorkflowSourceClass()
 {
     $this->specify('incorrect status id format', function () {
         $this->factory->getStatus('id', null, null);
     }, ['throws' => 'fproject\\workflow\\core\\WorkflowException']);
     $this->specify('empty provider fails to load workflow from non-existant workflow class', function () {
         $this->factory->getWorkflow('id', null);
     }, ['throws' => 'fproject\\workflow\\core\\WorkflowException']);
     $this->specify('empty provider fails to load status from non-existant workflow class', function () {
         $this->factory->getStatus('w/s', null, null);
     }, ['throws' => 'fproject\\workflow\\core\\WorkflowException']);
     $this->specify('empty provider fails to load transition from non-existant workflow class', function () {
         $this->factory->getTransitions('w/s', null, null);
     }, ['throws' => 'fproject\\workflow\\core\\WorkflowException']);
 }