@@ -25,7 +25,8 @@ |
||
| 25 | 25 | /** @inheritdoc */ |
| 26 | 26 | public function push(string $name, mixed $payload = [], OptionsInterface $options = null): string |
| 27 | 27 | { |
| 28 | - if ($options !== null && $options->getDelay()) { |
|
| 28 | + if ($options !== null && $options->getDelay()) |
|
| 29 | + { |
|
| 29 | 30 | \sleep($options->getDelay()); |
| 30 | 31 | } |
| 31 | 32 | |
@@ -24,15 +24,19 @@ |
||
| 24 | 24 | |
| 25 | 25 | public function handle(string $name, string $id, mixed $payload, array $headers = []): void |
| 26 | 26 | { |
| 27 | - try { |
|
| 27 | + try |
|
| 28 | + { |
|
| 28 | 29 | $params = ['payload' => $payload, 'id' => $id, 'headers' => $headers]; |
| 29 | 30 | |
| 30 | - if (\is_array($payload)) { |
|
| 31 | + if (\is_array($payload)) |
|
| 32 | + { |
|
| 31 | 33 | $params = \array_merge($params, $payload); |
| 32 | 34 | } |
| 33 | 35 | |
| 34 | 36 | $this->invoker->invoke([$this, $this->getHandlerMethod()], $params); |
| 35 | - } catch (\Throwable $e) { |
|
| 37 | + } |
|
| 38 | + catch (\Throwable $e) |
|
| 39 | + { |
|
| 36 | 40 | $message = \sprintf('[%s] %s', $this::class, $e->getMessage()); |
| 37 | 41 | throw new JobException($message, (int)$e->getCode(), $e); |
| 38 | 42 | } |
@@ -24,7 +24,8 @@ |
||
| 24 | 24 | $handler = m::mock(FailedJobHandlerInterface::class) |
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - if (!\is_array($payload)) { |
|
| 27 | + if (!\is_array($payload)) |
|
| 28 | + { |
|
| 28 | 29 | $this->markTestIncomplete('FailedJobHandlerInterface does not support non-array payloads'); |
| 29 | 30 | return; |
| 30 | 31 | } |
@@ -25,13 +25,15 @@ discard block |
||
| 25 | 25 | $queue = m::mock(QueueInterface::class) |
| 26 | 26 | ); |
| 27 | 27 | |
| 28 | - if (!\is_array($payload)) { |
|
| 28 | + if (!\is_array($payload)) |
|
| 29 | + { |
|
| 29 | 30 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
| 30 | 31 | return; |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | $queue->shouldReceive('push')->once() |
| 34 | - ->withArgs(function (string $name, mixed $p = [], OptionsInterface $options = null) use($payload) { |
|
| 35 | + ->withArgs(function (string $name, mixed $p = [], OptionsInterface $options = null) use($payload) |
|
| 36 | + { |
|
| 35 | 37 | return $name === 'foo' && $payload === $p && $options instanceof Options; |
| 36 | 38 | }); |
| 37 | 39 | |
@@ -51,7 +53,8 @@ discard block |
||
| 51 | 53 | $queue = m::mock(QueueInterface::class) |
| 52 | 54 | ); |
| 53 | 55 | |
| 54 | - if (!\is_array($payload)) { |
|
| 56 | + if (!\is_array($payload)) |
|
| 57 | + { |
|
| 55 | 58 | $this->markTestIncomplete('QueueInterface does not support non-array payloads'); |
| 56 | 59 | return; |
| 57 | 60 | } |
@@ -79,18 +82,21 @@ discard block |
||
| 79 | 82 | |
| 80 | 83 | |
| 81 | 84 | $tracer->shouldReceive('getContext')->once()->andReturn(['foo' => ['bar']]); |
| 82 | - $tracer->shouldReceive('trace')->once()->andReturnUsing(function ($name, $callback) { |
|
| 85 | + $tracer->shouldReceive('trace')->once()->andReturnUsing(function ($name, $callback) |
|
| 86 | + { |
|
| 83 | 87 | return $callback(); |
| 84 | 88 | }); |
| 85 | 89 | |
| 86 | 90 | $queue->shouldReceive('push')->once() |
| 87 | - ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) { |
|
| 91 | + ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) |
|
| 92 | + { |
|
| 88 | 93 | return $name === 'foo' |
| 89 | 94 | && $payload === ['baz' => 'baf'] |
| 90 | 95 | && $options->getHeader('foo') === ['bar']; |
| 91 | 96 | }); |
| 92 | 97 | |
| 93 | - ContainerScope::runScope($container, function() use($core) { |
|
| 98 | + ContainerScope::runScope($container, function() use($core) |
|
| 99 | + { |
|
| 94 | 100 | $core->callAction('foo', 'bar', [ |
| 95 | 101 | 'id' => 'job-id', |
| 96 | 102 | 'payload' => ['baz' => 'baf'], |
@@ -109,7 +115,8 @@ discard block |
||
| 109 | 115 | $tracer->shouldNotReceive('getContext'); |
| 110 | 116 | |
| 111 | 117 | $queue->shouldReceive('push')->once() |
| 112 | - ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) { |
|
| 118 | + ->withArgs(function (string $name, array $payload = [], OptionsInterface $options = null) |
|
| 119 | + { |
|
| 113 | 120 | return $name === 'foo' |
| 114 | 121 | && $payload === ['baz' => 'baf'] |
| 115 | 122 | && $options !== null; |