[Messenger] Ignore stamps in in-memory transport
This commit is contained in:
parent
a7fe2b29d2
commit
b435b1aab6
@ -13,6 +13,7 @@ namespace Symfony\Component\Messenger\Tests\Transport;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Messenger\Envelope;
|
use Symfony\Component\Messenger\Envelope;
|
||||||
|
use Symfony\Component\Messenger\Tests\Fixtures\AnEnvelopeStamp;
|
||||||
use Symfony\Component\Messenger\Transport\InMemoryTransport;
|
use Symfony\Component\Messenger\Transport\InMemoryTransport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,6 +51,19 @@ class InMemoryTransportTest extends TestCase
|
|||||||
$this->assertSame([], $this->transport->get());
|
$this->assertSame([], $this->transport->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAcknowledgeSameMessageWithDifferentStamps()
|
||||||
|
{
|
||||||
|
$envelope1 = new Envelope(new \stdClass(), [new AnEnvelopeStamp()]);
|
||||||
|
$this->transport->send($envelope1);
|
||||||
|
$envelope2 = new Envelope(new \stdClass(), [new AnEnvelopeStamp()]);
|
||||||
|
$this->transport->send($envelope2);
|
||||||
|
$this->assertSame([$envelope1, $envelope2], $this->transport->get());
|
||||||
|
$this->transport->ack($envelope1->with(new AnEnvelopeStamp()));
|
||||||
|
$this->assertSame([$envelope2], $this->transport->get());
|
||||||
|
$this->transport->reject($envelope2->with(new AnEnvelopeStamp()));
|
||||||
|
$this->assertSame([], $this->transport->get());
|
||||||
|
}
|
||||||
|
|
||||||
public function testAck()
|
public function testAck()
|
||||||
{
|
{
|
||||||
$envelope = new Envelope(new \stdClass());
|
$envelope = new Envelope(new \stdClass());
|
||||||
|
@ -55,7 +55,7 @@ class InMemoryTransport implements TransportInterface, ResetInterface
|
|||||||
public function ack(Envelope $envelope): void
|
public function ack(Envelope $envelope): void
|
||||||
{
|
{
|
||||||
$this->acknowledged[] = $envelope;
|
$this->acknowledged[] = $envelope;
|
||||||
$id = spl_object_hash($envelope);
|
$id = spl_object_hash($envelope->getMessage());
|
||||||
unset($this->queue[$id]);
|
unset($this->queue[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class InMemoryTransport implements TransportInterface, ResetInterface
|
|||||||
public function reject(Envelope $envelope): void
|
public function reject(Envelope $envelope): void
|
||||||
{
|
{
|
||||||
$this->rejected[] = $envelope;
|
$this->rejected[] = $envelope;
|
||||||
$id = spl_object_hash($envelope);
|
$id = spl_object_hash($envelope->getMessage());
|
||||||
unset($this->queue[$id]);
|
unset($this->queue[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class InMemoryTransport implements TransportInterface, ResetInterface
|
|||||||
public function send(Envelope $envelope): Envelope
|
public function send(Envelope $envelope): Envelope
|
||||||
{
|
{
|
||||||
$this->sent[] = $envelope;
|
$this->sent[] = $envelope;
|
||||||
$id = spl_object_hash($envelope);
|
$id = spl_object_hash($envelope->getMessage());
|
||||||
$this->queue[$id] = $envelope;
|
$this->queue[$id] = $envelope;
|
||||||
|
|
||||||
return $envelope;
|
return $envelope;
|
||||||
|
Reference in New Issue
Block a user