Skip to content

Commit ef29218

Browse files
Bound timeout workflow feature test
1 parent 695a2da commit ef29218

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

tests/Feature/TimeoutWorkflowTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace Tests\Feature;
66

7+
use RuntimeException;
78
use Tests\Fixtures\TestTimeoutWorkflow;
89
use Tests\TestCase;
10+
use Workflow\States\WorkflowFailedStatus;
911
use Workflow\WorkflowStub;
1012

1113
final class TimeoutWorkflowTest extends TestCase
@@ -16,8 +18,27 @@ public function testTimeout(): void
1618

1719
$workflow->start();
1820

19-
while ($workflow->running());
21+
$deadline = now()
22+
->addSeconds(20);
2023

24+
while ($workflow->running() && now()->lt($deadline)) {
25+
usleep(50000);
26+
$workflow->fresh();
27+
}
28+
29+
if ($workflow->running()) {
30+
throw new RuntimeException(sprintf(
31+
'Timed out waiting for activity timeout workflow %s to fail. Current status: %s; exceptions: %d; logs: %d',
32+
(string) $workflow->id(),
33+
(string) $workflow->status(),
34+
$workflow->exceptions()
35+
->count(),
36+
$workflow->logs()
37+
->count(),
38+
));
39+
}
40+
41+
$this->assertSame(WorkflowFailedStatus::class, $workflow->status());
2142
$this->assertSame(1, $workflow->exceptions()->count());
2243
}
2344
}

0 commit comments

Comments
 (0)