コード例 #1
0
 public function testRun()
 {
     $model = WorkflowTestHelper::createWorkflowModelTestItem('Green', '514');
     $timeTrigger = array('attributeIndexOrDerivedType' => 'string', 'operator' => OperatorRules::TYPE_EQUALS, 'value' => '514', 'durationInterval' => '5');
     $actions = array(array('type' => ActionForWorkflowForm::TYPE_UPDATE_SELF, ActionForWorkflowForm::ACTION_ATTRIBUTES => array('string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'))));
     $savedWorkflow = WorkflowTestHelper::createByTimeSavedWorkflow($timeTrigger, array(), $actions);
     WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($model, $savedWorkflow);
     $this->assertEquals(1, count(ByTimeWorkflowInQueue::getAll()));
     $job = new ByTimeWorkflowInQueueJob();
     $this->assertTrue($job->run());
     $this->assertEquals(0, count(ByTimeWorkflowInQueue::getAll()));
     $this->assertEquals('jason', $model->string);
 }
コード例 #2
0
 public function testPagedRun()
 {
     $model = WorkflowTestHelper::createWorkflowModelTestItem('Blue', '514');
     $timeTrigger = array('attributeIndexOrDerivedType' => 'string', 'operator' => OperatorRules::TYPE_EQUALS, 'value' => '514', 'durationInterval' => '5');
     $actions = array(array('type' => ActionForWorkflowForm::TYPE_UPDATE_SELF, ActionForWorkflowForm::ACTION_ATTRIBUTES => array('string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'))));
     $savedWorkflow = WorkflowTestHelper::createByTimeSavedWorkflow($timeTrigger, array(), $actions);
     for ($index = 0; $index < 10; $index++) {
         WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($model, $savedWorkflow);
     }
     InQueueBatchSizeConfigUtil::setBatchSize(5);
     Yii::app()->jobQueue->deleteAll();
     $this->assertCount(0, Yii::app()->jobQueue->getAll());
     $this->assertEquals(10, count(ByTimeWorkflowInQueue::getAll()));
     $job = new ByTimeWorkflowInQueueJob();
     $this->assertTrue($job->run());
     $this->assertEquals(5, count(ByTimeWorkflowInQueue::getAll()));
     $jobs = Yii::app()->jobQueue->getAll();
     $this->assertCount(1, $jobs);
     $this->assertEquals('ByTimeWorkflowInQueue', $jobs[key($jobs)][0]['jobType']);
     Yii::app()->jobQueue->deleteAll();
     $this->assertTrue($job->run());
     $this->assertEquals(0, count(ByTimeWorkflowInQueue::getAll()));
     $this->assertCount(0, Yii::app()->jobQueue->getAll());
 }
 public function testMassDeletePagesProperlyAndRemovesAllSelectedForByTimeWorkflowInQueue()
 {
     //MassDelete for selected Record Count
     $byTimeWorkflowInQueue01 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue02 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue03 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue04 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue05 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue06 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue07 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue08 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue09 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     $byTimeWorkflowInQueue10 = WorkflowTestHelper::createExpiredByTimeWorkflowInQueue($this->model, $this->savedWorkflow);
     //save Model MassDelete for entire search result
     $this->setGetArray(array('selectAll' => '1', 'ByTimeWorkflowInQueue_page' => 1));
     $this->setPostArray(array('selectedRecordCount' => 10));
     //Run Mass Delete using progress save for page1.
     $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
     $this->assertEquals(5, $pageSize);
     $this->runControllerWithExitExceptionAndGetContent('workflows/defaultTimeQueue/massDelete');
     //check for previous mass delete progress
     $models = ByTimeWorkflowInQueue::getAll();
     $this->assertEquals(5, count($models));
     $this->setGetArray(array('selectAll' => '1', 'ByTimeWorkflowInQueue_page' => 2));
     $this->setPostArray(array('selectedRecordCount' => 10));
     //Run Mass Delete using progress save for page2.
     $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
     $this->assertEquals(5, $pageSize);
     $this->runControllerWithNoExceptionsAndGetContent('workflows/defaultTimeQueue/massDeleteProgress');
     //calculating count
     $models = ByTimeWorkflowInQueue::getAll();
     $this->assertEquals(0, count($models));
 }