Skip to content

Commit 9edbd48

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: (47 commits) Remove comment about AppVeyor in `phpunit` [Webhook][RemoteEvent] fix SendgridPayloadConverter category support Update old Appveyor skip conditions sync the Dutch translation file with changes from the 7.2 branch [Yaml] fix inline notation with inline comment clean up code for doctrine/persistence 2.x Generate missing translations using Gemini fix(property-info): make sure that SerializerExtractor returns null for invalid class metadata add translations for the Slug constraint [RemoteEvent][Webhook] fix SendgridRequestParser & SendgridPayloadConverter in case of missing sg_message_id [Messenger] Fix `TransportMessageIdStamp` not always added [DoctrineBridge] Fix compatibility to Doctrine persistence 2.5 in Doctrine Bridge 6.4 to avoid Projects stuck on 6.3 [PropertyInfo] Fix add missing composer conflict [ErrorHandler] Don't trigger "internal" deprecations for anonymous LazyClosure instances [VarDumper] Fix displaying closure's "this" from anonymous classes [Doctrine][Messenger] Prevents multiple TransportMessageIdStamp being stored in envelope [HttpKernel] Don't override existing LoggerInterface autowiring alias in LoggerPass reject inline notations followed by invalid content Fix predis command error checking [Security] Fix triggering session tracking from ContextListener ...
2 parents f100c8d + cbedb5a commit 9edbd48

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

Tests/Transport/BeanstalkdReceiverTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Messenger\Bridge\Beanstalkd\Transport\Connection;
1919
use Symfony\Component\Messenger\Envelope;
2020
use Symfony\Component\Messenger\Exception\MessageDecodingFailedException;
21+
use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
2122
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
2223
use Symfony\Component\Messenger\Transport\Serialization\Serializer;
2324
use Symfony\Component\Serializer as SerializerComponent;
@@ -40,14 +41,21 @@ public function testItReturnsTheDecodedMessageToTheHandler()
4041
$receiver = new BeanstalkdReceiver($connection, $serializer);
4142
$actualEnvelopes = $receiver->get();
4243
$this->assertCount(1, $actualEnvelopes);
43-
$this->assertEquals(new DummyMessage('Hi'), $actualEnvelopes[0]->getMessage());
44+
/** @var Envelope $actualEnvelope */
45+
$actualEnvelope = $actualEnvelopes[0];
46+
$this->assertEquals(new DummyMessage('Hi'), $actualEnvelope->getMessage());
4447

4548
/** @var BeanstalkdReceivedStamp $receivedStamp */
46-
$receivedStamp = $actualEnvelopes[0]->last(BeanstalkdReceivedStamp::class);
49+
$receivedStamp = $actualEnvelope->last(BeanstalkdReceivedStamp::class);
4750

4851
$this->assertInstanceOf(BeanstalkdReceivedStamp::class, $receivedStamp);
4952
$this->assertSame('1', $receivedStamp->getId());
5053
$this->assertSame($tube, $receivedStamp->getTube());
54+
55+
/** @var TransportMessageIdStamp $transportMessageIdStamp */
56+
$transportMessageIdStamp = $actualEnvelope->last(TransportMessageIdStamp::class);
57+
$this->assertNotNull($transportMessageIdStamp);
58+
$this->assertSame('1', $transportMessageIdStamp->getId());
5159
}
5260

5361
public function testItReturnsEmptyArrayIfThereAreNoMessages()

Tests/Transport/BeanstalkdSenderTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Messenger\Bridge\Beanstalkd\Transport\Connection;
1919
use Symfony\Component\Messenger\Envelope;
2020
use Symfony\Component\Messenger\Stamp\DelayStamp;
21+
use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
2122
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
2223

2324
final class BeanstalkdSenderTest extends TestCase
@@ -28,13 +29,21 @@ public function testSend()
2829
$encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class]];
2930

3031
$connection = $this->createMock(Connection::class);
31-
$connection->expects($this->once())->method('send')->with($encoded['body'], $encoded['headers'], 0, null);
32+
$connection->expects($this->once())->method('send')
33+
->with($encoded['body'], $encoded['headers'], 0, null)
34+
->willReturn('1')
35+
;
3236

3337
$serializer = $this->createMock(SerializerInterface::class);
3438
$serializer->method('encode')->with($envelope)->willReturn($encoded);
3539

3640
$sender = new BeanstalkdSender($connection, $serializer);
37-
$sender->send($envelope);
41+
$actualEnvelope = $sender->send($envelope);
42+
43+
/** @var TransportMessageIdStamp $transportMessageIdStamp */
44+
$transportMessageIdStamp = $actualEnvelope->last(TransportMessageIdStamp::class);
45+
$this->assertNotNull($transportMessageIdStamp);
46+
$this->assertSame('1', $transportMessageIdStamp->getId());
3847
}
3948

4049
public function testSendWithDelay()

Transport/BeanstalkdReceiver.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface;
1919
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
2020
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
21+
use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
2122

2223
/**
2324
* @author Antonio Pauletich <[email protected]>
@@ -52,7 +53,12 @@ public function get(): iterable
5253
throw $exception;
5354
}
5455

55-
return [$envelope->with(new BeanstalkdReceivedStamp($beanstalkdEnvelope['id'], $this->connection->getTube()))];
56+
return [$envelope
57+
->withoutAll(TransportMessageIdStamp::class)
58+
->with(
59+
new BeanstalkdReceivedStamp($beanstalkdEnvelope['id'], $this->connection->getTube()),
60+
new TransportMessageIdStamp($beanstalkdEnvelope['id']),
61+
)];
5662
}
5763

5864
public function ack(Envelope $envelope): void

Transport/BeanstalkdSender.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Messenger\Envelope;
1515
use Symfony\Component\Messenger\Stamp\DelayStamp;
16+
use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
1617
use Symfony\Component\Messenger\Transport\Sender\SenderInterface;
1718
use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer;
1819
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
@@ -35,13 +36,13 @@ public function send(Envelope $envelope): Envelope
3536
{
3637
$encodedMessage = $this->serializer->encode($envelope);
3738

38-
$this->connection->send(
39+
$id = $this->connection->send(
3940
$encodedMessage['body'],
4041
$encodedMessage['headers'] ?? [],
4142
$envelope->last(DelayStamp::class)?->getDelay() ?? 0,
4243
$envelope->last(BeanstalkdPriorityStamp::class)?->priority,
4344
);
4445

45-
return $envelope;
46+
return $envelope->with(new TransportMessageIdStamp($id));
4647
}
4748
}

0 commit comments

Comments
 (0)