|
17 | 17 | use Workflow\V2\Models\WorkflowInstance; |
18 | 18 | use Workflow\V2\Models\WorkflowRun; |
19 | 19 | use Workflow\V2\Models\WorkflowTask; |
20 | | -use Workflow\V2\Models\WorkflowUpdate; |
21 | 20 | use Workflow\V2\Support\MessageStreamCursor; |
22 | 21 | use Workflow\V2\WorkflowStub; |
23 | 22 |
|
@@ -151,99 +150,6 @@ public function testMultipleSignalsBeforeContinueAsNewTransferCursorCorrectly(): |
151 | 150 | $this->assertSame('Alice', $workflow->output()['name']); |
152 | 151 | } |
153 | 152 |
|
154 | | - public function testAcceptedInstanceUpdateTransfersThroughContinueAsNew(): void |
155 | | - { |
156 | | - Queue::fake(); |
157 | | - |
158 | | - $workflow = WorkflowStub::make(TestConfiguredContinueSignalWorkflow::class, 'cursor-continue-update-1'); |
159 | | - $workflow->start(0); |
160 | | - |
161 | | - $update = $workflow->submitUpdate('mark-approved', true); |
162 | | - |
163 | | - $this->assertTrue($update->accepted()); |
164 | | - $this->assertSame('accepted', $update->status()); |
165 | | - |
166 | | - /** @var WorkflowUpdate $acceptedUpdate */ |
167 | | - $acceptedUpdate = WorkflowUpdate::query()->findOrFail($update->updateId()); |
168 | | - $firstRunId = $workflow->runId(); |
169 | | - |
170 | | - $this->assertSame($firstRunId, $acceptedUpdate->workflow_run_id); |
171 | | - |
172 | | - $this->drainReadyTasks(); |
173 | | - |
174 | | - $this->waitFor(static fn (): bool => $workflow->refresh()->status() === 'waiting' |
175 | | - && $workflow->summary()?->wait_kind === 'signal'); |
176 | | - |
177 | | - $runs = WorkflowRun::query() |
178 | | - ->where('workflow_instance_id', 'cursor-continue-update-1') |
179 | | - ->orderBy('run_number') |
180 | | - ->get(); |
181 | | - |
182 | | - $this->assertCount(2, $runs); |
183 | | - |
184 | | - $firstRun = $runs[0]; |
185 | | - $secondRun = $runs[1]; |
186 | | - |
187 | | - $acceptedUpdate->refresh(); |
188 | | - |
189 | | - $this->assertSame($firstRunId, $firstRun->id); |
190 | | - $this->assertSame($secondRun->id, $acceptedUpdate->workflow_run_id); |
191 | | - $this->assertSame($secondRun->id, $acceptedUpdate->resolved_workflow_run_id); |
192 | | - $this->assertSame('completed', $acceptedUpdate->status->value); |
193 | | - $this->assertSame(1, (int) $acceptedUpdate->workflow_sequence); |
194 | | - $this->assertSame([ |
195 | | - 'approved' => true, |
196 | | - 'count' => 1, |
197 | | - ], $acceptedUpdate->updateResult()); |
198 | | - |
199 | | - $command = WorkflowCommand::query()->findOrFail($update->commandId()); |
200 | | - |
201 | | - $this->assertSame($secondRun->id, $command->workflow_run_id); |
202 | | - $this->assertSame($secondRun->id, $command->resolved_workflow_run_id); |
203 | | - |
204 | | - $this->assertSame(1, WorkflowHistoryEvent::query() |
205 | | - ->where('workflow_run_id', $firstRun->id) |
206 | | - ->where('event_type', HistoryEventType::UpdateAccepted->value) |
207 | | - ->count()); |
208 | | - $this->assertSame(1, WorkflowHistoryEvent::query() |
209 | | - ->where('workflow_run_id', $secondRun->id) |
210 | | - ->where('event_type', HistoryEventType::UpdateAccepted->value) |
211 | | - ->where('workflow_command_id', $command->id) |
212 | | - ->count()); |
213 | | - $this->assertSame(1, WorkflowHistoryEvent::query() |
214 | | - ->where('workflow_run_id', $secondRun->id) |
215 | | - ->where('event_type', HistoryEventType::UpdateApplied->value) |
216 | | - ->where('workflow_command_id', $command->id) |
217 | | - ->count()); |
218 | | - $this->assertSame(1, WorkflowHistoryEvent::query() |
219 | | - ->where('workflow_run_id', $secondRun->id) |
220 | | - ->where('event_type', HistoryEventType::UpdateCompleted->value) |
221 | | - ->where('workflow_command_id', $command->id) |
222 | | - ->count()); |
223 | | - |
224 | | - $query = $workflow->query('current-approval'); |
225 | | - |
226 | | - $this->assertSame([ |
227 | | - 'approved' => true, |
228 | | - 'count' => 1, |
229 | | - ], $query); |
230 | | - |
231 | | - $signal = $workflow->signal('name-provided', 'Taylor'); |
232 | | - |
233 | | - $this->assertTrue($signal->accepted()); |
234 | | - |
235 | | - $this->drainReadyTasks(); |
236 | | - |
237 | | - $this->waitFor(static fn (): bool => $workflow->refresh()->completed()); |
238 | | - |
239 | | - $this->assertSame([ |
240 | | - 'name' => 'Taylor', |
241 | | - 'approved' => true, |
242 | | - 'workflow_id' => 'cursor-continue-update-1', |
243 | | - 'run_id' => $secondRun->id, |
244 | | - ], $workflow->output()); |
245 | | - } |
246 | | - |
247 | 153 | private function waitFor(callable $condition): void |
248 | 154 | { |
249 | 155 | $deadline = microtime(true) + 30; |
|
0 commit comments