-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathExceptionTest.php
More file actions
46 lines (37 loc) · 1.47 KB
/
Copy pathExceptionTest.php
File metadata and controls
46 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Tests\Unit;
use Tests\Fixtures\TestWorkflow;
use Tests\TestCase;
use Workflow\Exception;
use Workflow\Middleware\WithoutOverlappingMiddleware;
use Workflow\Models\StoredWorkflow;
use Workflow\Serializers\Serializer;
use Workflow\States\WorkflowRunningStatus;
use Workflow\WorkflowStub;
final class ExceptionTest extends TestCase
{
public function testMiddleware(): void
{
$exception = new Exception(0, now()->toDateTimeString(), new StoredWorkflow(), new \Exception(
'Test exception'
));
$middleware = collect($exception->middleware())
->map(static fn ($middleware) => is_object($middleware) ? get_class($middleware) : $middleware)
->values();
$this->assertCount(1, $middleware);
$this->assertSame([WithoutOverlappingMiddleware::class], $middleware->all());
}
public function testExceptionWorkflowRunning(): void
{
$workflow = WorkflowStub::load(WorkflowStub::make(TestWorkflow::class)->id());
$storedWorkflow = StoredWorkflow::findOrFail($workflow->id());
$storedWorkflow->update([
'arguments' => Serializer::serialize([]),
'status' => WorkflowRunningStatus::$name,
]);
$exception = new Exception(0, now()->toDateTimeString(), $storedWorkflow, new \Exception('Test exception'));
$exception->handle();
$this->assertSame(WorkflowRunningStatus::class, $workflow->status());
}
}