Skip to content

[Messenger] Fix tests #43915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Transport\InMemoryTransport;
use Symfony\Component\Messenger\Transport\InMemoryTransportFactory;
Expand Down Expand Up @@ -61,7 +62,7 @@ public function testCreateTransportWithoutSerializer()
$message = Envelope::wrap(new DummyMessage('Hello.'));
$transport->send($message);

$this->assertSame([$message], $transport->get());
$this->assertEquals([$message->with(new TransportMessageIdStamp(1))], $transport->get());
}

public function testCreateTransportWithSerializer()
Expand All @@ -72,7 +73,7 @@ public function testCreateTransportWithSerializer()
$serializer
->expects($this->once())
->method('encode')
->with($this->equalTo($message))
->with($this->equalTo($message->with(new TransportMessageIdStamp(1))))
;
$transport = $this->factory->createTransport('in-memory://?serialize=true', [], $serializer);
$transport->send($message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp;
use Symfony\Component\Messenger\Tests\Fixtures\AnEnvelopeStamp;
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
use Symfony\Component\Messenger\Transport\InMemoryTransport;
Expand Down Expand Up @@ -49,7 +50,7 @@ public function testSend()
{
$envelope = new Envelope(new \stdClass());
$this->transport->send($envelope);
$this->assertSame([$envelope], $this->transport->getSent());
$this->assertEquals([$envelope->with(new TransportMessageIdStamp(1))], $this->transport->getSent());
}

public function testSendWithSerialization()
Expand All @@ -58,7 +59,7 @@ public function testSendWithSerialization()
$envelopeDecoded = Envelope::wrap(new DummyMessage('Hello.'));
$this->serializer
->method('encode')
->with($this->equalTo($envelope))
->with($this->equalTo($envelope->with(new TransportMessageIdStamp(1))))
->willReturn(['foo' => 'ba'])
;
$this->serializer
Expand Down Expand Up @@ -89,7 +90,7 @@ public function testQueueWithSerialization()
$envelopeDecoded = Envelope::wrap(new DummyMessage('Hello.'));
$this->serializer
->method('encode')
->with($this->equalTo($envelope))
->with($this->equalTo($envelope->with(new TransportMessageIdStamp(1))))
->willReturn(['foo' => 'ba'])
;
$this->serializer
Expand Down Expand Up @@ -128,15 +129,15 @@ public function testAckWithSerialization()
$envelopeDecoded = Envelope::wrap(new DummyMessage('Hello.'));
$this->serializer
->method('encode')
->with($this->equalTo($envelope))
->with($this->equalTo($envelope->with(new TransportMessageIdStamp(1))))
->willReturn(['foo' => 'ba'])
;
$this->serializer
->method('decode')
->with(['foo' => 'ba'])
->willReturn($envelopeDecoded)
;
$this->serializeTransport->ack($envelope);
$this->serializeTransport->ack($envelope->with(new TransportMessageIdStamp(1)));
$this->assertSame([$envelopeDecoded], $this->serializeTransport->getAcknowledged());
}

Expand All @@ -154,15 +155,15 @@ public function testRejectWithSerialization()
$envelopeDecoded = Envelope::wrap(new DummyMessage('Hello.'));
$this->serializer
->method('encode')
->with($this->equalTo($envelope))
->with($this->equalTo($envelope->with(new TransportMessageIdStamp(1))))
->willReturn(['foo' => 'ba'])
;
$this->serializer
->method('decode')
->with(['foo' => 'ba'])
->willReturn($envelopeDecoded)
;
$this->serializeTransport->reject($envelope);
$this->serializeTransport->reject($envelope->with(new TransportMessageIdStamp(1)));
$this->assertSame([$envelopeDecoded], $this->serializeTransport->getRejected());
}

Expand Down