Repository: symfony/symfony
File: src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineTransportTest.php (PHP)

Code before:
        $decodedMessage = new DummyMessage('Decoded.');

        $doctrineEnvelope = [
            'id' => '5',
            'body' => 'body',
            'headers' => ['my' => 'header'],
        ];

        $serializer->method('decode')->with(['body' => 'body', 'headers' => ['my' => 'header']])->willReturn(new Envelope($decodedMessage));
        $connection->method('get')->willReturn($doctrineEnvelope);

        $envelopes = $transport->get();
        $this->assertSame($decodedMessage, $envelopes[0]->getMessage());
    }

    public function testConfigureSchema()
    {
        $transport = $this->getTransport(
            null,
            $connection = $this->createMock(Connection::class)
        );

        $schema = new Schema();
        $dbalConnection = $this->createMock(DbalConnection::class);

        $isSameDatabaseChecker = static fn() => true;
        $connection->expects($this->once())
            ->method('configureSchema')
            ->with($schema, $dbalConnection, $isSameDatabaseChecker);

        $transport->configureSchema($schema, $dbalConnection, $isSameDatabaseChecker);
    }

    public function testKeepalive()
    {
        $transport = $this->getTransport(
            null,
            $connection = $this->createMock(Connection::class)
        );

        $envelope = new Envelope(new \stdClass(), [new DoctrineReceivedStamp('1')]);

        $connection->expects($this->once())
            ->method('keepalive')
            ->with('1');

        $transport->keepalive($envelope);
    }

    private function getTransport(?SerializerInterface $serializer = null, ?Connection $connection = null): DoctrineTransport
    {

Review comment (suggestion):
```suggestion
        $isSameDatabaseChecker = static fn () => true;
```

Code after:
        $decodedMessage = new DummyMessage('Decoded.');

        $doctrineEnvelope = [
            'id' => '5',
            'body' => 'body',
            'headers' => ['my' => 'header'],
        ];

        $serializer->method('decode')->with(['body' => 'body', 'headers' => ['my' => 'header']])->willReturn(new Envelope($decodedMessage));
        $connection->method('get')->willReturn($doctrineEnvelope);

        $envelopes = $transport->get();
        $this->assertSame($decodedMessage, $envelopes[0]->getMessage());
    }

    public function testConfigureSchema()
    {
        $transport = $this->getTransport(
            null,
            $connection = $this->createMock(Connection::class)
        );

        $schema = new Schema();
        $dbalConnection = $this->createMock(DbalConnection::class);

        $isSameDatabaseChecker = static fn () => true;
        $connection->expects($this->once())
            ->method('configureSchema')
            ->with($schema, $dbalConnection, $isSameDatabaseChecker);

        $transport->configureSchema($schema, $dbalConnection, $isSameDatabaseChecker);
    }

    public function testKeepalive()
    {
        $transport = $this->getTransport(
            null,
            $connection = $this->createMock(Connection::class)
        );

        $envelope = new Envelope(new \stdClass(), [new DoctrineReceivedStamp('1')]);

        $connection->expects($this->once())
            ->method('keepalive')
            ->with('1');

        $transport->keepalive($envelope);
    }

    private function getTransport(?SerializerInterface $serializer = null, ?Connection $connection = null): DoctrineTransport
    {