|
17 | 17 | // 2 exits |
18 | 18 | WorkflowTransitionFactory::new()->workflow($workflow->id)->from($mid1->to_id)->exit()->create(); |
19 | 19 | WorkflowTransitionFactory::new()->workflow($workflow->id)->from($mid2->to_id)->exit()->create(); |
| 20 | + |
| 21 | + |
| 22 | + $this->secondaryWorkflow = $workflow = WorkflowFactory::new()->create(); |
| 23 | + WorkflowTransitionFactory::new()->workflow($this->secondaryWorkflow->id)->entry()->create(); |
20 | 24 | }); |
21 | 25 |
|
22 | 26 | test('it has correct relationships', function () { |
|
50 | 54 | $status = $modelB->getDefaultWorkflow()->entryTransitions->first()->toStatus; |
51 | 55 |
|
52 | 56 | expect($modelB->modelStatus->status)->toEqual($modelB->getStatus())->toEqual($status) |
53 | | - ->and($modelB->modelStatus->workflow)->toEqual($modelB->getDefaultWorkflow()) |
| 57 | + ->and($modelB->modelStatus->workflow->id)->toEqual($modelB->getDefaultWorkflow()?->id) |
54 | 58 | ->and($modelB->modelStatuses)->toHaveCount(1); |
55 | 59 | }); |
56 | 60 |
|
|
92 | 96 | expect($model->isAllowed($this->mid1))->toBeFalse(); |
93 | 97 | }); |
94 | 98 |
|
| 99 | +test('it deletes model statuses when model is deleted', function () { |
| 100 | + ($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save(); |
| 101 | + expect(WorkflowModelStatus::count())->toBe(1); |
| 102 | + |
| 103 | + $model->delete(); |
| 104 | + expect(WorkflowModelStatus::count())->toBe(0); |
| 105 | +}); |
| 106 | + |
| 107 | +test('it queries by workflow', function () { |
| 108 | + ($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save(); |
| 109 | + |
| 110 | + expect(WorkflowableModel::query()->inWorkflow($this->workflow->name)->count())->toBe(1) |
| 111 | + ->and(WorkflowableModel::query()->inWorkflow($this->secondaryWorkflow->name)->count())->toBe(0); |
| 112 | +}); |
| 113 | + |
95 | 114 | test('it has toString', function () { |
96 | 115 | ($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save(); |
97 | 116 |
|
|
0 commit comments