|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\Messenger\Exception\InvalidArgumentException;
|
| 16 | +use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage; |
16 | 17 | use Symfony\Component\Messenger\Transport\AmqpExt\AmqpFactory;
|
| 18 | +use Symfony\Component\Messenger\Transport\AmqpExt\AmqpStamp; |
17 | 19 | use Symfony\Component\Messenger\Transport\AmqpExt\Connection;
|
18 | 20 |
|
19 | 21 | /**
|
@@ -430,7 +432,7 @@ public function testItCanPublishWithASuppliedRoutingKey()
|
430 | 432 | $amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key');
|
431 | 433 |
|
432 | 434 | $connection = Connection::fromDsn('amqp://localhost/%2f/messages?exchange[default_publish_routing_key]=default_routing_key', [], $factory);
|
433 |
| - $connection->publish('body', [], 0, 'routing_key'); |
| 435 | + $connection->publish('body', [], 0, new AmqpStamp('routing_key')); |
434 | 436 | }
|
435 | 437 |
|
436 | 438 | public function testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument()
|
@@ -477,7 +479,27 @@ public function testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument
|
477 | 479 | $delayQueue->expects($this->once())->method('bind')->with('delay', 'delay_120000');
|
478 | 480 |
|
479 | 481 | $delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_120000', AMQP_NOPARAM, ['headers' => []]);
|
480 |
| - $connection->publish('{}', [], 120000, 'routing_key'); |
| 482 | + $connection->publish('{}', [], 120000, new AmqpStamp('routing_key')); |
| 483 | + } |
| 484 | + |
| 485 | + public function testItCanPublishWithCustomFlagsAndAttributes() |
| 486 | + { |
| 487 | + $factory = new TestAmqpFactory( |
| 488 | + $amqpConnection = $this->createMock(\AMQPConnection::class), |
| 489 | + $amqpChannel = $this->createMock(\AMQPChannel::class), |
| 490 | + $amqpQueue = $this->createMock(\AMQPQueue::class), |
| 491 | + $amqpExchange = $this->createMock(\AMQPExchange::class) |
| 492 | + ); |
| 493 | + |
| 494 | + $amqpExchange->expects($this->once())->method('publish')->with( |
| 495 | + 'body', |
| 496 | + 'routing_key', |
| 497 | + AMQP_IMMEDIATE, |
| 498 | + ['delivery_mode' => 2, 'headers' => ['type' => DummyMessage::class]] |
| 499 | + ); |
| 500 | + |
| 501 | + $connection = Connection::fromDsn('amqp://localhost/%2f/messages', [], $factory); |
| 502 | + $connection->publish('body', ['type' => DummyMessage::class], 0, new AmqpStamp('routing_key', AMQP_IMMEDIATE, ['delivery_mode' => 2])); |
481 | 503 | }
|
482 | 504 | }
|
483 | 505 |
|
|
0 commit comments