/** * @expectedException yii\base\InvalidConfigException */ public function testAttachBehaviorFails3() { //$this->specify('the status attribute must exist in the owner model', function () { $model = new Item01(); $model->detachBehavior('workflow'); $model->attachBehavior('workflow', ['class' => ActiveWorkflowBehavior::className(), 'statusAttribute' => 'not_found']); //},['throws' => 'yii\base\InvalidConfigException']); }
public function testConfiguredWorkflowId() { $this->specify('use the configured workflow Id', function () { /** @var ActiveWorkflowBehavior|Item01 $model */ $model = new Item01(); $model->attachBehavior('workflow', ['class' => ActiveWorkflowBehavior::className(), 'defaultWorkflowId' => 'myWorkflow']); expect('model should have workflow id set to "myWorkflow"', $model->getDefaultWorkflowId() == 'myWorkflow')->true(); }); }
protected function setup() { parent::setUp(); $this->eventsBefore = []; $this->eventsAfter = []; Yii::$app->set('workflowFactory', ['class' => 'fproject\\workflow\\core\\ArrayWorkflowItemFactory', 'workflowSourceNamespace' => 'tests\\codeception\\unit\\models']); Yii::$app->set('eventSequence', ['class' => 'fproject\\workflow\\events\\ReducedEventSequence']); $this->model = new Item04(); $this->model->attachBehavior('workflow', ['class' => ActiveWorkflowBehavior::className()]); }
public function testConvertionOnLeaveWorkflow() { /** @var Item04|ActiveWorkflowBehavior $item */ $item = new Item04(); $item->attachBehavior('workflow', ['class' => ActiveWorkflowBehavior::className(), 'statusConverter' => 'converter']); $this->assertEquals(null, $item->status); $this->assertEquals('Item04Workflow/B', $item->getWorkflowStatus()->getId()); $this->specify('convertion is done when leaving workflow', function () use($item) { $item->sendToStatus(null); expect('item to not be in a workflow', $item->getWorkflow())->equals(null); expect('item to not have status', $item->hasWorkflowStatus())->false(); expect('status attribut to be converted into 55', $item->status)->equals(55); }); }
public function testInitStatusAfterFindSuccess() { $this->specify('status initialisation when reading model from db (after find)', function () { /** @var Item01|ActiveWorkflowBehavior $model */ $model = new Item01(); $model->detachBehavior('workflow'); $model->id = 1; $model->name = 'name'; $model->status = 'Workflow1/B'; $model->save(false); $model = Item01::findOne(1); $model->attachBehavior('workflow', ['class' => ActiveWorkflowBehavior::className(), 'defaultWorkflowId' => 'Workflow1']); verify('current model status is "B"', $model->getWorkflowStatus()->getId())->equals('Workflow1/B'); }); }
public function testGetNextStatusFails() { /** @var Item04|ActiveWorkflowBehavior $item */ $item = new Item04(); $item->detachBehavior('workflow'); $item->attachBehavior('workflowForTest', ['class' => ActiveWorkflowBehavior::className(), 'defaultWorkflowId' => 'INVALID_ID']); $this->specify('getNextStatus throws exception if default workflow Id is invalid', function () use($item) { $this->setExpectedException('fproject\\workflow\\core\\WorkflowException', "Invalid workflow Id : 'INVALID_ID'"); $item->getNextStatuses(); }); }
public function behaviors() { return ['workflow' => ['class' => ActiveWorkflowBehavior::className()]]; }
/** * @expectedException fproject\workflow\core\WorkflowException * @expectedExceptionMessage Failed to load workflow definition : Class tests\codeception\unit\models\NOTFOUNDSource does not exist */ public function testAutoInsertFails2() { $o = new Item00(); $o->attachBehavior('workflow', ['class' => ActiveWorkflowBehavior::className(), 'autoInsert' => 'NOTFOUND', 'defaultWorkflowId' => 'Item04Workflow']); }
/** * (non-PHPdoc) * @see \yii\base\Component::behaviors() */ public function behaviors() { return ['w1' => ['class' => ActiveWorkflowBehavior::className(), 'defaultWorkflowId' => 'Item08Workflow1'], 'w2' => ['class' => ActiveWorkflowBehavior::className(), 'statusAttribute' => 'status_ex', 'defaultWorkflowId' => 'Item08Workflow2']]; }
public function behaviors() { return ['workflow' => ['class' => ActiveWorkflowBehavior::className(), 'statusAttribute' => 'statusAlias', 'statusAccessor' => 'status_accessor']]; }
/** * (non-PHPdoc) * @see \yii\base\Component::behaviors() */ public function behaviors() { return ['wf' => ['class' => ActiveWorkflowBehavior::className(), 'idAccessor' => 'wfIdAccessor']]; }