Inheritance: extends yii\db\ActiveRecord
 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']));
 }
Example #2
0
 public function testValidateFailsOnToStatus()
 {
     /** @var ActiveWorkflowBehavior|Item05 $model */
     $model = new Item05();
     $model->sendToStatus('Item05Workflow/new');
     $model->sendToStatus('Item05Workflow/correction');
     expect_that($model->getWorkflowStatus()->getId() == 'Item05Workflow/correction');
     $this->specify('model validation success on enter status "published" for attribute "author"', function () use($model) {
         $model->status = 'Item05Workflow/published';
         $model->tags = 'some tag';
         $model->author = null;
         verify('validation error', $model->validate())->false();
         verify('the model has errors', $model->hasErrors())->true();
         verify('the model has exactly one error', count($model->getErrors()) == 1)->true();
         verify('the correct error message is set', $model->getFirstError('author'))->equals('Author cannot be blank.');
     });
 }