Skip to content

Commit a06b497

Browse files
authored
Merge pull request #145 from lorenzolosa/bugfix_double_transition
Fix bug on two consecutive transitions
2 parents 9618705 + 203877c commit a06b497

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/State.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public function transition(Transition $transition): Model
152152
}
153153

154154
$model = app()->call([$transition, 'handle']);
155+
$model->{$this->field}->setField($this->field);
155156

156157
event(new StateChanged(
157158
$this,

tests/TransitionTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,19 @@ public function event_is_triggered_after_transition()
163163
&& $event->model->is($model);
164164
});
165165
}
166+
167+
/** @test */
168+
public function can_transition_twice()
169+
{
170+
$model = TestModel::create([
171+
'state' => StateA::class,
172+
]);
173+
174+
$model->state->transitionTo(StateB::class);
175+
$model->state->transitionTo(StateC::class);
176+
177+
$model->refresh();
178+
179+
$this->assertInstanceOf(StateC::class, $model->state);
180+
}
166181
}

0 commit comments

Comments
 (0)