8000 [messenger] Moves testing sending messages with a routing key to a de… · symfony/symfony@24b96e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24b96e6

Browse files
author
Guillaume Gammelin
committed
[messenger] Moves testing sending messages with a routing key to a dedicated test method.
Also includes rebase fixes.
1 parent 7f60247 commit 24b96e6

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@
2525
class AmqpSenderTest extends TestCase
2626
{
2727
public function testItSendsTheEncodedMessage()
28+
{
29+
$envelope = new Envelope(new DummyMessage('Oy'));
30+
$encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]];
31+
32+
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
33+
$serializer->method('encode')->with($envelope)->willReturnOnConsecutiveCalls($encoded);
34+
35+
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
36+
$connection->expects($this->once())->method('publish')->with($encoded['body'], $encoded['headers']);
37+
38+
$sender = new AmqpSender($connection, $serializer);
39+
$sender->send($envelope);
40+
}
41+
42+
public function testItSendsTheEncodedMessageUsingARoutingKey()
2843
{
2944
$envelope = (new Envelope(new DummyMessage('Oy')))->with(new RoutingKeyStamp('rk'));
3045
$encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]];

src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function testItCanPublishWithTheDefaultQueueRoutingKey()
267267

268268
$amqpExchange->expects($this->once())->method('publish')->with('body', 'my_key');
269269

270-
$connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[routing_key]=my_key', [], true, $factory);
270+
$connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[routing_key]=my_key', [], $factory);
271271
$connection->publish('body');
272272
}
273273

@@ -282,7 +282,7 @@ public function testItCanPublishWithASuppliedRoutingKey()
282282

283283
$amqpExchange->expects($this->once())->method('publish')->with('body', 'supplied_key');
284284

285-
$connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[routing_key]=my_key', [], true, $factory);
285+< 8000 div class="diff-text-inner"> $connection = Connection::fromDsn('amqp://localhost/%2f/messages?queue[routing_key]=my_key', [], $factory);
286286
$connection->publish('body', [], 'supplied_key');
287287
}
288288
}

src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function send(Envelope $envelope): Envelope
4848
$routingKey = $routingKeyStamp ? $routingKeyStamp->getRoutingKey() : null;
4949

5050
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers'] ?? [], $routingKey);
51-
$this->connection->publish($encodedMessage['body'], $encodedMessage['headers'] ?? []);
5251
} catch (\AMQPException $e) {
5352
throw new TransportException($e->getMessage(), 0, $e);
5453
}

0 commit comments

Comments
 (0)
0