@@ -28,22 +28,59 @@ public function testSupportsOnlyRedisTransports()
28
28
29
29
$ this ->assertTrue ($ factory ->supports ('redis://localhost ' , []));
30
30
$ 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 ' , []));
31
32
$ this ->assertFalse ($ factory ->supports ('sqs://localhost ' , []));
32
33
$ this ->assertFalse ($ factory ->supports ('invalid-dsn ' , []));
33
34
}
34
35
35
36
/**
36
37
* @group integration
38
+ *
39
+ * @dataProvider createTransportProvider
37
40
*/
38
- public function testCreateTransport ()
41
+ public function testCreateTransport (string $ dsn , array $ options = [] )
39
42
{
40
43
$ this ->skipIfRedisUnavailable ();
41
44
42
45
$ factory = new RedisTransportFactory ();
43
46
$ serializer = $ this ->createMock (SerializerInterface::class);
44
- $ expectedTransport = new RedisTransport (Connection::fromDsn ('redis:// ' .getenv ('REDIS_HOST ' ), ['stream ' => 'bar ' , 'delete_after_ack ' => true ]), $ serializer );
45
47
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 createTransportProvider (): 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
+
47
84
}
48
85
49
86
private function skipIfRedisUnavailable ()
0 commit comments