예제 #1
0
 public function testReturnReportWithNothing()
 {
     /** @var Item05|ActiveWorkflowBehavior $model */
     // prepare
     $model = new Item05();
     $model->status = 'Item05Workflow/new';
     verify_that($model->save());
     // test
     $report = $model->getNextStatuses();
     $this->assertCount(2, $report, ' report contains 2 entries as 2 statuses can be reached from "new"');
     $this->assertArrayHasKey('Item05Workflow/correction', $report, '  a transition exists between "new" and "correction" ');
     $this->assertArrayHasKey('Item05Workflow/published', $report, '  a transition exists between "new" and "published" ');
     $this->assertTrue(!isset($report['Item05Workflow/correction']['isValid']));
     $this->assertTrue(!isset($report['Item05Workflow/correction']['validation']));
     $this->assertTrue(!isset($report['Item05Workflow/correction']['event']));
     $this->assertTrue(!isset($report['Item05Workflow/published']['isValid']));
     $this->assertTrue(!isset($report['Item05Workflow/published']['validation']));
     $this->assertTrue(!isset($report['Item05Workflow/published']['event']));
 }
예제 #2
0
 public function testValidateSuccessOnLeaveWorkflow()
 {
     /** @var ActiveWorkflowBehavior|Item05 $model */
     $model = new Item05();
     $model->status = 'Item05Workflow/new';
     expect_that($model->save());
     expect_that($model->getWorkflowStatus()->getId() == 'Item05Workflow/new');
     $this->specify('model validation success on leave workflow for attribute "category"', function () use($model) {
         $model->status = null;
         // leaving workflow
         $model->category = 'done';
         verify('validation success', $model->validate())->true();
         verify('the model has no error', $model->hasErrors())->false();
         verify('the model status was not changed', $model->getWorkflowStatus()->getId())->equals('Item05Workflow/new');
         verify('the status attribute is NULL', $model->status)->equals(null);
     });
 }