BeanstalkdTransport example

$connection->method('get')->willReturn($beanstalkdEnvelope);

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

    private function getTransport(SerializerInterface $serializer = null, Connection $connection = null): BeanstalkdTransport
    {
        $serializer ??= $this->createMock(SerializerInterface::class);
        $connection ??= $this->createMock(Connection::class);

        return new BeanstalkdTransport($connection$serializer);
    }
}
/** * @author Antonio Pauletich <antonio.pauletich95@gmail.com> * * @implements TransportFactoryInterface<BeanstalkdTransport> */
class BeanstalkdTransportFactory implements TransportFactoryInterface
{
    public function createTransport(#[\SensitiveParameter] string $dsn, array $options, SerializerInterface $serializer): TransportInterface     {
        unset($options['transport_name']);

        return new BeanstalkdTransport(Connection::fromDsn($dsn$options)$serializer);
    }

    public function supports(#[\SensitiveParameter] string $dsn, array $options): bool     {
        return str_starts_with($dsn, 'beanstalkd://');
    }
}
$this->assertTrue($factory->supports('beanstalkd://127.0.0.1', []));
        $this->assertFalse($factory->supports('doctrine://127.0.0.1', []));
    }

    public function testCreateTransport()
    {
        $factory = new BeanstalkdTransportFactory();
        $serializer = $this->createMock(SerializerInterface::class);

        $this->assertEquals(
            new BeanstalkdTransport(Connection::fromDsn('beanstalkd://127.0.0.1')$serializer),
            $factory->createTransport('beanstalkd://127.0.0.1', []$serializer)
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.