Skip to content

Commit

Permalink
Fix the passing of queue_headers #67
Browse files Browse the repository at this point in the history
Fix the passing of queue_headers
  • Loading branch information
msmakouz authored Jun 25, 2024
2 parents ab1e4ff + d3ee263 commit 9842316
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Jobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function toStringOfStringMap(array $map): array
\is_string($value) => $value,
\is_bool($value) => $value ? 'true' : 'false',
$value instanceof \JsonSerializable,
\is_array($value) => \json_encode($value, \JSON_THROW_ON_ERROR | (empty($value)? \JSON_FORCE_OBJECT : 0)),
\is_array($value) => \json_encode($value, \JSON_THROW_ON_ERROR),
default => throw new \InvalidArgumentException(
\sprintf('Can not cast to string unrecognized value of type %s', \get_debug_type($value)),
),
Expand Down
5 changes: 4 additions & 1 deletion src/Queue/AMQPCreateInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public function toArray(): array
'requeue_on_fail' => $this->requeueOnFail,
'durable' => $this->durable,
'consume_all' => $this->consumeAll,
'queue_headers' => $this->queueHeaders,
'delete_queue_on_stop' => $this->deleteQueueOnStop,
'redial_timeout' => $this->redialTimeout,
]);
Expand All @@ -93,6 +92,10 @@ public function toArray(): array
$result['consumer_id'] = $this->consumerId;
}

if ($this->queueHeaders !== []) {
$result['queue_headers'] = $this->queueHeaders;
}

return $result;
}
}
7 changes: 7 additions & 0 deletions tests/Unit/Queue/AMQPCreateInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,11 @@ public function testToArray(): void

$this->assertEquals($expectedArray, $amqpCreateInfo->toArray());
}

public function testToArrayWithEmptyQueueHeaders(): void
{
$amqpCreateInfo = new AMQPCreateInfo(name: 'foo');

$this->assertArrayNotHasKey('queue_headers', $amqpCreateInfo->toArray());
}
}

0 comments on commit 9842316

Please sign in to comment.