Allow exchange type headers binding
This commit is contained in:
parent
ff63bb325d
commit
3211caa5b5
@ -273,6 +273,33 @@ class ConnectionTest extends TestCase
|
|||||||
$connection->publish('body');
|
$connection->publish('body');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBindingArguments()
|
||||||
|
{
|
||||||
|
$amqpConnection = $this->createMock(\AMQPConnection::class);
|
||||||
|
$amqpChannel = $this->createMock(\AMQPChannel::class);
|
||||||
|
$amqpExchange = $this->createMock(\AMQPExchange::class);
|
||||||
|
$amqpQueue = $this->createMock(\AMQPQueue::class);
|
||||||
|
|
||||||
|
$factory = $this->createMock(AmqpFactory::class);
|
||||||
|
$factory->method('createConnection')->willReturn($amqpConnection);
|
||||||
|
$factory->method('createChannel')->willReturn($amqpChannel);
|
||||||
|
$factory->method('createExchange')->willReturn($amqpExchange);
|
||||||
|
$factory->method('createQueue')->willReturn($amqpQueue);
|
||||||
|
|
||||||
|
$amqpExchange->expects($this->once())->method('declareExchange');
|
||||||
|
$amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => []]);
|
||||||
|
$amqpQueue->expects($this->once())->method('declareQueue');
|
||||||
|
$amqpQueue->expects($this->exactly(1))->method('bind')->withConsecutive(
|
||||||
|
[self::DEFAULT_EXCHANGE_NAME, null, ['x-match' => 'all']]
|
||||||
|
);
|
||||||
|
|
||||||
|
$dsn = 'amqp://localhost?exchange[type]=headers'.
|
||||||
|
'&queues[queue0][binding_arguments][x-match]=all';
|
||||||
|
|
||||||
|
$connection = Connection::fromDsn($dsn, [], $factory);
|
||||||
|
$connection->publish('body');
|
||||||
|
}
|
||||||
|
|
||||||
public function testItCanDisableTheSetup()
|
public function testItCanDisableTheSetup()
|
||||||
{
|
{
|
||||||
$factory = new TestAmqpFactory(
|
$factory = new TestAmqpFactory(
|
||||||
|
@ -81,6 +81,7 @@ class Connection
|
|||||||
* * password: Password to use the connect to the AMQP service
|
* * password: Password to use the connect to the AMQP service
|
||||||
* * queues[name]: An array of queues, keyed by the name
|
* * queues[name]: An array of queues, keyed by the name
|
||||||
* * binding_keys: The binding keys (if any) to bind to this queue
|
* * binding_keys: The binding keys (if any) to bind to this queue
|
||||||
|
* * binding_arguments: Arguments to be used while binding the queue.
|
||||||
* * flags: Queue flags (Default: AMQP_DURABLE)
|
* * flags: Queue flags (Default: AMQP_DURABLE)
|
||||||
* * arguments: Extra arguments
|
* * arguments: Extra arguments
|
||||||
* * exchange:
|
* * exchange:
|
||||||
@ -349,7 +350,7 @@ class Connection
|
|||||||
foreach ($this->queuesOptions as $queueName => $queueConfig) {
|
foreach ($this->queuesOptions as $queueName => $queueConfig) {
|
||||||
$this->queue($queueName)->declareQueue();
|
$this->queue($queueName)->declareQueue();
|
||||||
foreach ($queueConfig['binding_keys'] ?? [null] as $bindingKey) {
|
foreach ($queueConfig['binding_keys'] ?? [null] as $bindingKey) {
|
||||||
$this->queue($queueName)->bind($this->exchangeOptions['name'], $bindingKey);
|
$this->queue($queueName)->bind($this->exchangeOptions['name'], $bindingKey, $queueConfig['binding_arguments'] ?? []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user