Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c821bc

Browse files
committed
Add tests
1 parent fedf007 commit 1c821bc

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisTransportFactoryTest.php

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,59 @@ public function testSupportsOnlyRedisTransports()
2828

2929
$this->assertTrue($factory->supports('redis://localhost', []));
3030
$this->assertTrue($factory->supports('rediss://localhost', []));
31+
$this->assertTrue($factory->supports('redis:?host[host1:5000]&host[host2:5000]&host[host3:5000]&sentinel_master=test&dbindex=0', []));
3132
$this->assertFalse($factory->supports('sqs://localhost', []));
3233
$this->assertFalse($factory->supports('invalid-dsn', []));
3334
}
3435

3536
/**
3637
* @group integration
38+
*
39+
* @dataProvider createProvider
3740
*/
38-
public function testCreateTransport()
41+
public function testCreateTransport(string $dsn, array $options = [])
3942
{
4043
$this->skipIfRedisUnavailable();
4144

4245
$factory = new RedisTransportFactory();
4346
$serializer = $this->createMock(SerializerInterface::class);
44-
$expectedTransport = new RedisTransport(Connection::fromDsn('redis://'.getenv('REDIS_HOST'), ['stream' => 'bar', 'delete_after_ack' => true]), $serializer);
4547

46-
$this->assertEquals($expectedTransport, $factory->createTransport('redis://'.getenv('REDIS_HOST'), ['stream' => 'bar', 'delete_after_ack' => true], $serializer));
48+
$this->assertEquals(
49+
new RedisTransport(Connection::fromDsn($dsn, $options), $serializer),
50+
$factory->createTransport($dsn, $options, $serializer)
51+
);
52+
}
53+
54+
/**
55+
* @return iterable<array{0: string, 1: array}>
56+
*/
57+
public static function createProvider(): iterable
58+
{
59+
yield 'scheme "redis" without options' => [
60+
'redis://'.getenv('REDIS_HOST'),
61+
[],
62+
];
63+
64+
yield 'scheme "rediss" without options' => [
65+
'rediss://'.getenv('REDIS_HOST'),
66+
[],
67+
];
68+
69+
yield 'scheme "redis" with options' => [
70+
'redis://'.getenv('REDIS_HOST'),
71+
['stream' => 'bar', 'delete_after_ack' => true],
72+
];
73+
74+
yield 'scheme "rediss" with options' => [
75+
'rediss://'.getenv('REDIS_HOST'),
76+
['stream' => 'bar', 'delete_after_ack' => true],
77+
];
78+
79+
yield 'redis_sentinel' => [
80+
'redis:?host[host1:5000]&host[host2:5000]&host[host3:5000]&sentinel_master=test&dbindex=0',
81+
[],
82+
];
83+
4784
}
4885

4986
private function skipIfRedisUnavailable()

0 commit comments

Comments
 (0)