diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisTransportFactoryTest.php b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisTransportFactoryTest.php index 5c7caff199ea0..93e5e890fd471 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisTransportFactoryTest.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisTransportFactoryTest.php @@ -28,22 +28,48 @@ public function testSupportsOnlyRedisTransports() $this->assertTrue($factory->supports('redis://localhost', [])); $this->assertTrue($factory->supports('rediss://localhost', [])); + $this->assertTrue($factory->supports('redis:?host[host1:5000]&host[host2:5000]&host[host3:5000]&sentinel_master=test&dbindex=0', [])); $this->assertFalse($factory->supports('sqs://localhost', [])); $this->assertFalse($factory->supports('invalid-dsn', [])); } /** * @group integration + * + * @dataProvider createTransportProvider */ - public function testCreateTransport() + public function testCreateTransport(string $dsn, array $options = []) { $this->skipIfRedisUnavailable(); $factory = new RedisTransportFactory(); $serializer = $this->createMock(SerializerInterface::class); - $expectedTransport = new RedisTransport(Connection::fromDsn('redis://'.getenv('REDIS_HOST'), ['stream' => 'bar', 'delete_after_ack' => true]), $serializer); - $this->assertEquals($expectedTransport, $factory->createTransport('redis://'.getenv('REDIS_HOST'), ['stream' => 'bar', 'delete_after_ack' => true], $serializer)); + $this->assertEquals( + new RedisTransport(Connection::fromDsn($dsn, $options), $serializer), + $factory->createTransport($dsn, $options, $serializer) + ); + } + + /** + * @return iterable + */ + public static function createTransportProvider(): iterable + { + yield 'scheme "redis" without options' => [ + 'redis://'.getenv('REDIS_HOST'), + [], + ]; + + yield 'scheme "redis" with options' => [ + 'redis://'.getenv('REDIS_HOST'), + ['stream' => 'bar', 'delete_after_ack' => true], + ]; + + yield 'redis_sentinel' => [ + 'redis:?host['.str_replace(' ', ']&host[', getenv('REDIS_SENTINEL_HOSTS')).']', + ['sentinel_master' => getenv('REDIS_SENTINEL_SERVICE')], + ]; } private function skipIfRedisUnavailable() diff --git a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/RedisTransportFactory.php b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/RedisTransportFactory.php index f7e9956809ba2..89ebf6ee119be 100644 --- a/src/Symfony/Component/Messenger/Bridge/Redis/Transport/RedisTransportFactory.php +++ b/src/Symfony/Component/Messenger/Bridge/Redis/Transport/RedisTransportFactory.php @@ -32,6 +32,6 @@ public function createTransport(#[\SensitiveParameter] string $dsn, array $optio public function supports(#[\SensitiveParameter] string $dsn, array $options): bool { - return str_starts_with($dsn, 'redis://') || str_starts_with($dsn, 'rediss://'); + return str_starts_with($dsn, 'redis:') || str_starts_with($dsn, 'rediss:'); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy