Skip to content

Commit f19fcdf

Browse files
committed
2 parents 570e189 + a50c7b2 commit f19fcdf

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/Traits/HasWorkflows.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function isInFinalStatus(): bool
231231
protected function createModelStatus(Workflow $workflow, WorkflowStatus $status): WorkflowModelStatus
232232
{
233233
$wmsClass = config('workflow.workflow_model_status_class');
234-
$modelStatus = new $wmsClass();
234+
$modelStatus = new $wmsClass;
235235
$modelStatus->model()->associate($this);
236236
$modelStatus->user()->associate(Auth::user());
237237
$modelStatus->workflow()->associate($workflow);

tests/Feature/MultipleWorkflowTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
});
3131

3232
test('it supports multiple models', function () {
33-
($modelA = new WorkflowableModel())->setDefaultWorkflowName($this->workflowA->name)->save();
34-
($modelB = new WorkflowableModel())->setDefaultWorkflowName($this->workflowB->name)->save();
33+
($modelA = new WorkflowableModel)->setDefaultWorkflowName($this->workflowA->name)->save();
34+
($modelB = new WorkflowableModel)->setDefaultWorkflowName($this->workflowB->name)->save();
3535

3636
expect($modelA->modelStatus->workflow)->id->toBe($this->workflowA->id);
3737
expect($modelB->modelStatus->workflow)->id->toEqual($this->workflowB->id);
@@ -57,7 +57,7 @@
5757
});
5858

5959
test('a model can have multiple workflows', function () {
60-
($modelA = new WorkflowableModel())->setDefaultWorkflowName($this->workflowA->name)->save();
60+
($modelA = new WorkflowableModel)->setDefaultWorkflowName($this->workflowA->name)->save();
6161
$modelA->transition($this->entryA_to_A1);
6262

6363
expect($modelA->usingWorkflow($this->workflowB)->getCurrentWorkflow())

tests/Feature/WorkflowTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@
3737
});
3838

3939
test('it creates the first status for a newly created model', function () {
40-
(new WorkflowableModel())->save();
40+
(new WorkflowableModel)->save();
4141
expect(WorkflowModelStatus::count())->toBe(0);
4242

43-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
43+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
4444
expect(WorkflowModelStatus::first())
4545
->count()->toBe(1)
4646
->model->id->toBe($model->id);
4747
});
4848

4949
test('it gets the status(es) of a model', function () {
50-
($modelA = new WorkflowableModel())->save();
50+
($modelA = new WorkflowableModel)->save();
5151
expect($modelA->modelStatuses)->toHaveCount(0);
5252

53-
($modelB = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
53+
($modelB = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
5454
$status = $modelB->getDefaultWorkflow()->entryTransitions->first()->toStatus;
5555

5656
expect($modelB->modelStatus->status)->toEqual($modelB->getStatus())->toEqual($status)
@@ -59,7 +59,7 @@
5959
});
6060

6161
test('it can transition a model', function () {
62-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
62+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
6363
$transitions = $model->possibleTransitions();
6464

6565
expect($transitions)->toHaveCount(1);
@@ -71,22 +71,22 @@
7171
});
7272

7373
test('it fails transition if not valid', function () {
74-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
74+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
7575
$transitions = $model->possibleTransitions();
7676

7777
expect(fn () => $model->transitionTo($transitions->first()->fromStatus))
7878
->toThrow(InvalidTransitionException::class);
7979
});
8080

8181
test('it can filter model with specific status', function () {
82-
(new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
82+
(new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
8383

8484
expect(WorkflowableModel::inStatus($this->entry->toStatus, $this->workflow)->get())->toHaveCount(1)
8585
->and(WorkflowableModel::inStatus($this->mid1->toStatus->id, $this->workflow)->get())->toHaveCount(0);
8686
});
8787

8888
test('it checks if a transition is allowed', function () {
89-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
89+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
9090

9191
expect($model->isAllowed($this->mid1))->toBeTrue()
9292
->and($model->isAllowed($this->entry->toStatus))->toBeFalse();
@@ -112,7 +112,7 @@
112112
});
113113

114114
test('it has toString', function () {
115-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
115+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
116116

117117
expect($model->getCurrentWorkflow()?->__toString())->toBe($model->getCurrentWorkflow()->name);
118118
expect($model->possibleTransitions()->first()->__toString())->toContain($model->getCurrentWorkflow()?->__toString());

tests/Feature/WorkflowsPermissionsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
});
2424

2525
test('it can transition if no permissions are defined', function () {
26-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
26+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
2727
/** @var \Squarebit\Workflows\Models\WorkflowTransition $transition */
2828
$transition = $model->possibleTransitions()->first();
2929

@@ -32,7 +32,7 @@
3232
});
3333

3434
test('it cannot transition if user is missing necessary permissions', function () {
35-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
35+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
3636
/** @var \Squarebit\Workflows\Models\WorkflowTransition $transition */
3737
$transition = $model->possibleTransitions()->first();
3838

@@ -42,7 +42,7 @@
4242
});
4343

4444
test('it can transition when user has necessary permission', function () {
45-
($model = new WorkflowableModel())->setDefaultWorkflowName($this->workflow->name)->save();
45+
($model = new WorkflowableModel)->setDefaultWorkflowName($this->workflow->name)->save();
4646
/** @var \Squarebit\Workflows\Models\WorkflowTransition $transition */
4747
$transition = $model->possibleTransitions()->first();
4848

tests/Support/2000_01_01_000000_create_permission_tables.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
use Illuminate\Support\Facades\Schema;
4-
use Illuminate\Database\Schema\Blueprint;
53
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
66
use Spatie\Permission\PermissionRegistrar;
77

88
class CreatePermissionTables extends Migration

0 commit comments

Comments
 (0)