|
5 | 5 | namespace Tests\Unit; |
6 | 6 |
|
7 | 7 | use Exception; |
| 8 | +use RuntimeException; |
8 | 9 | use Tests\Fixtures\TestActivity; |
9 | 10 | use Tests\Fixtures\TestWorkflow; |
10 | 11 | use Tests\TestCase; |
@@ -92,6 +93,36 @@ public function testLoadsStoredException(): void |
92 | 93 | $this->assertSame('test', $result['message']); |
93 | 94 | } |
94 | 95 |
|
| 96 | + public function testLoadsStoredExceptionWithNonStandardConstructor(): void |
| 97 | + { |
| 98 | + $this->expectException(RuntimeException::class); |
| 99 | + $this->expectExceptionMessage( |
| 100 | + '[' . ActivityStubNonStandardConstructorException::class . '] test from context (1)' |
| 101 | + ); |
| 102 | + $this->expectExceptionCode(123); |
| 103 | + |
| 104 | + $workflow = WorkflowStub::load(WorkflowStub::make(TestWorkflow::class)->id()); |
| 105 | + $storedWorkflow = StoredWorkflow::findOrFail($workflow->id()); |
| 106 | + $storedWorkflow->update([ |
| 107 | + 'arguments' => Serializer::serialize([]), |
| 108 | + 'status' => WorkflowPendingStatus::$name, |
| 109 | + ]); |
| 110 | + $storedWorkflow->logs() |
| 111 | + ->create([ |
| 112 | + 'index' => 0, |
| 113 | + 'now' => WorkflowStub::now(), |
| 114 | + 'class' => TestActivity::class, |
| 115 | + 'result' => Serializer::serialize( |
| 116 | + new ActivityStubNonStandardConstructorException('context', 'test', ['binding'], 123) |
| 117 | + ), |
| 118 | + ]); |
| 119 | + |
| 120 | + ActivityStub::make(TestActivity::class) |
| 121 | + ->then(static function ($value) use (&$result) { |
| 122 | + $result = $value; |
| 123 | + }); |
| 124 | + } |
| 125 | + |
95 | 126 | public function testAll(): void |
96 | 127 | { |
97 | 128 | $workflow = WorkflowStub::load(WorkflowStub::make(TestWorkflow::class)->id()); |
@@ -142,3 +173,11 @@ public function testAsync(): void |
142 | 173 | $this->assertSame('test', $result); |
143 | 174 | } |
144 | 175 | } |
| 176 | + |
| 177 | +final class ActivityStubNonStandardConstructorException extends Exception |
| 178 | +{ |
| 179 | + public function __construct(string $connection, string $message, array $bindings, int $code) |
| 180 | + { |
| 181 | + parent::__construct($message . ' from ' . $connection . ' (' . count($bindings) . ')', $code); |
| 182 | + } |
| 183 | +} |
0 commit comments