getStatus() public method

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').
See also: raoul2000\workflow\source\IWorkflowSource::getStatus
public getStatus ( string $id, mixed $defaultWorkflowId = null ) : Status
$id string ID of the status to get
$defaultWorkflowId mixed model instance used to resolve the status ID or workflow ID
return raoul2000\workflow\base\Status the status instance
 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);
 }
Esempio n. 2
0
 /**
  * @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);
     });
 }
Esempio n. 3
0
 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');
     });
 }