Skip to content

Commit f260071

Browse files
committed
Fix active
1 parent 4d14c85 commit f260071

5 files changed

Lines changed: 21 additions & 74 deletions

File tree

src/Models/StoredWorkflow.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,12 @@ public function active(): self
127127
$active = $this->fresh();
128128

129129
if ($active->status::class === WorkflowContinuedStatus::class) {
130-
$active = $this->activeWorkflow()
130+
$continued = $this->activeWorkflow()
131131
->first();
132+
133+
if ($continued !== null) {
134+
$active = $continued;
135+
}
132136
}
133137

134138
return $active;

tests/Feature/ContinueAsNewBatchWorkflowTest.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/Fixtures/ProcessRecordActivity.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/Fixtures/TestBatchContinueAsNewWorkflow.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/Unit/Models/StoredWorkflowTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,20 @@ public function testActiveWorkflowWithMultipleContinuations(): void
233233

234234
$this->assertSame($finalWorkflow->id, $active->id);
235235
}
236+
237+
public function testActiveWithContinuedStatusButNoActiveChild(): void
238+
{
239+
$workflow = StoredWorkflow::create([
240+
'class' => 'TestWorkflow',
241+
'status' => WorkflowRunningStatus::class,
242+
'arguments' => json_encode([]),
243+
]);
244+
245+
$workflow->status->transitionTo(WorkflowContinuedStatus::class);
246+
247+
$active = $workflow->active();
248+
249+
$this->assertNotNull($active);
250+
$this->assertSame($workflow->id, $active->id);
251+
}
236252
}

0 commit comments

Comments
 (0)