Skip to content

Commit bfb3a65

Browse files
Import Deferred in probe code
1 parent 5f61620 commit bfb3a65

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/Traits/SideEffects.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Workflow\Traits;
66

77
use Illuminate\Database\QueryException;
8+
use React\Promise\Deferred;
89
use React\Promise\PromiseInterface;
910
use function React\Promise\resolve;
1011
use Workflow\Serializers\Serializer;
@@ -22,7 +23,7 @@ public static function sideEffect($callable): PromiseInterface
2223

2324
if (self::isProbing()) {
2425
++self::$context->index;
25-
return (new \React\Promise\Deferred())->promise();
26+
return (new Deferred())->promise();
2627
}
2728

2829
$result = $callable();

src/Traits/Versions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Workflow\Traits;
66

77
use Illuminate\Database\QueryException;
8+
use React\Promise\Deferred;
89
use React\Promise\PromiseInterface;
910
use function React\Promise\resolve;
1011
use Workflow\Exceptions\VersionNotSupportedException;
@@ -35,7 +36,7 @@ public static function getVersion(
3536

3637
if (self::isProbing()) {
3738
++self::$context->index;
38-
return (new \React\Promise\Deferred())->promise();
39+
return (new Deferred())->promise();
3940
}
4041

4142
$version = $maxSupported;

tests/Unit/ExceptionTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Tests\Unit;
66

7+
use Exception as BaseException;
8+
use InvalidArgumentException;
9+
use RuntimeException;
710
use Tests\Fixtures\TestProbeBackToBackWorkflow;
811
use Tests\Fixtures\TestProbeChildFailureWorkflow;
912
use Tests\Fixtures\TestProbeParallelChildWorkflow;
@@ -21,7 +24,7 @@ final class ExceptionTest extends TestCase
2124
{
2225
public function testMiddleware(): void
2326
{
24-
$exception = new Exception(0, now()->toDateTimeString(), new StoredWorkflow(), new \Exception(
27+
$exception = new Exception(0, now()->toDateTimeString(), new StoredWorkflow(), new BaseException(
2528
'Test exception'
2629
));
2730

@@ -42,7 +45,7 @@ public function testExceptionWorkflowRunning(): void
4245
'status' => WorkflowRunningStatus::$name,
4346
]);
4447

45-
$exception = new Exception(0, now()->toDateTimeString(), $storedWorkflow, new \Exception('Test exception'));
48+
$exception = new Exception(0, now()->toDateTimeString(), $storedWorkflow, new BaseException('Test exception'));
4649
$exception->handle();
4750

4851
$this->assertSame(WorkflowRunningStatus::class, $workflow->status());
@@ -64,14 +67,14 @@ public function testSkipsWriteWhenProbeDoesNotReachCandidateException(): void
6467
->toDateTimeString(),
6568
'class' => Exception::class,
6669
'result' => Serializer::serialize([
67-
'class' => \Exception::class,
70+
'class' => BaseException::class,
6871
'message' => 'child failed: child-1',
6972
'code' => 0,
7073
]),
7174
]);
7275

7376
$exception = new Exception(1, now()->toDateTimeString(), $storedWorkflow, [
74-
'class' => \Exception::class,
77+
'class' => BaseException::class,
7578
'message' => 'child failed: child-2',
7679
'code' => 0,
7780
], sourceClass: TestProbeChildFailureWorkflow::class);
@@ -97,14 +100,14 @@ public function testPersistsWriteWhenProbeReachesCandidateException(): void
97100
->toDateTimeString(),
98101
'class' => Exception::class,
99102
'result' => Serializer::serialize([
100-
'class' => \RuntimeException::class,
103+
'class' => RuntimeException::class,
101104
'message' => 'first failure',
102105
'code' => 0,
103106
]),
104107
]);
105108

106109
$exception = new Exception(1, now()->toDateTimeString(), $storedWorkflow, [
107-
'class' => \InvalidArgumentException::class,
110+
'class' => InvalidArgumentException::class,
108111
'message' => 'second failure',
109112
'code' => 0,
110113
], sourceClass: TestProbeRetryActivity::class);

0 commit comments

Comments
 (0)