/** * @depends testCreateProperlySetsNullAlternativeValues */ public function testUpdateSelf() { $action = new ActionForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE); $action->type = ActionForWorkflowForm::TYPE_UPDATE_SELF; $attributes = array('string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason')); $action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes)); $model = new WorkflowModelTestItem(); $helper = new WorkflowActionProcessingHelper(88, 'some name', $action, $model, Yii::app()->user->userModel); $helper->processUpdateSelfAction(); $this->assertEquals('jason', $model->string); $this->assertTrue($model->id < 0); }
/** * Process any workflow actions that are updates to the passed in model during the processing of any * ByTimeWorkflowQueue models. @see ByTimeWorkflowInQueueJob. * @param Workflow $workflow * @param RedBeanModel $model * @param User $triggeredByUser * @throws FailedToSaveModelException */ public static function processOnByTimeWorkflowInQueueJob(Workflow $workflow, RedBeanModel $model, User $triggeredByUser) { foreach ($workflow->getActions() as $action) { try { $helper = new WorkflowActionProcessingHelper((int) $workflow->getId(), $workflow->getName(), $action, $model, $triggeredByUser, false); $helper->processUpdateSelfAction(); $helper->processNonUpdateSelfAction(); } catch (Exception $e) { WorkflowUtil::handleProcessingException($e, 'application.modules.workflows.utils.WorkflowActionsUtil.processOnByTimeWorkflowInQueueJob'); } } }