示例#1
0
 public function testWorkflowCached()
 {
     $this->factory->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => ['A']]);
     $this->specify('workflow are loaded once', function () {
         verify('workflow instances are the same', spl_object_hash($this->factory->getWorkflow('wid', null)))->equals(spl_object_hash($this->factory->getWorkflow('wid', null)));
     });
 }
示例#2
0
 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);
 }
示例#3
0
 public function testClassMapStatus()
 {
     $this->specify('Replace default status class with custom one', function () {
         $factory = new ArrayWorkflowItemFactory(['workflowSourceNamespace' => 'tests\\codeception\\unit\\models', 'classMap' => [ArrayWorkflowItemFactory::CLASS_MAP_STATUS => 'tests\\codeception\\unit\\models\\MyStatus']]);
         verify($factory->getClassMapByType(ArrayWorkflowItemFactory::CLASS_MAP_WORKFLOW))->equals('fproject\\workflow\\core\\Workflow');
         verify($factory->getClassMapByType(ArrayWorkflowItemFactory::CLASS_MAP_STATUS))->equals('tests\\codeception\\unit\\models\\MyStatus');
         verify($factory->getClassMapByType(ArrayWorkflowItemFactory::CLASS_MAP_TRANSITION))->equals('fproject\\workflow\\core\\Transition');
         $status = $factory->getStatus('Item04Workflow/A', null, null);
         expect(get_class($status))->equals('tests\\codeception\\unit\\models\\MyStatus');
     });
 }
示例#4
0
 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 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']);
 }