If this status was never loaded before, it is loaded now and stored (cached) for later use.
If a $model is provided, it must be a BaseActiveRecord instance with a SimpleWorkflowBehavior attached. This model
is used to complete the status ID if the one defined by the $id argument is not complete (e.g. 'draft' instead of 'post/draft').
public function testLoadWorkflowSuccess2() { $src = new WorkflowFileSource(); $src->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => ['A' => ['label' => 'Entry', 'transition' => 'A,B'], 'B' => ['label' => 'Published', 'transition' => ' A , B ']]]); verify($src->getStatus('wid/A'))->notNull(); verify($src->getStatus('wid/B'))->notNull(); verify(count($src->getTransitions('wid/A')))->equals(2); }
/** * @expectedException raoul2000\workflow\base\WorkflowValidationException * @expectedExceptionMessageRegExp #No status definition found# */ public function testStatusNotFoundSuccess() { $src = new WorkflowFileSource(); $src->addWorkflowDefinition('wid', ['initialStatusId' => 'A', 'status' => null]); $this->specify('status is not found', function () use($src) { $status = $src->getStatus('wid/A'); verify('a Workflow instance is returned', $status)->equals(null); }); }
public function testClassMapStatus() { $this->specify('Replace default status class with custom one', function () { $src = new WorkflowFileSource(['definitionLoader' => ['class' => 'raoul2000\\workflow\\source\\file\\PhpClassLoader', 'namespace' => 'tests\\codeception\\unit\\models'], 'classMap' => [WorkflowFileSource::TYPE_STATUS => 'tests\\codeception\\unit\\models\\MyStatus']]); verify($src->getClassMapByType(WorkflowFileSource::TYPE_WORKFLOW))->equals('raoul2000\\workflow\\base\\Workflow'); verify($src->getClassMapByType(WorkflowFileSource::TYPE_STATUS))->equals('tests\\codeception\\unit\\models\\MyStatus'); verify($src->getClassMapByType(WorkflowFileSource::TYPE_TRANSITION))->equals('raoul2000\\workflow\\base\\Transition'); $status = $src->getStatus('Item04Workflow/A'); expect(get_class($status))->equals('tests\\codeception\\unit\\models\\MyStatus'); }); }