@@ -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
+ * @dataProvider createProvider
37
39
*/
38
- public function testCreateTransport ()
40
+ public function testCreateTransport (string $ dsn , array $ options = [] )
39
41
{
40
42
$ this ->skipIfRedisUnavailable ();
41
43
42
44
$ factory = new RedisTransportFactory ();
43
45
$ serializer = $ this ->createMock (SerializerInterface::class);
44
- $ expectedTransport = new RedisTransport (Connection::fromDsn ('redis:// ' .getenv ('REDIS_HOST ' ), ['stream ' => 'bar ' , 'delete_after_ack ' => true ]), $ serializer );
45
46
46
- $ this ->assertEquals ($ expectedTransport , $ factory ->createTransport ('redis:// ' .getenv ('REDIS_HOST ' ), ['stream ' => 'bar ' , 'delete_after_ack ' => true ], $ serializer ));
47
+ $ this ->assertEquals (
48
+ new RedisTransport (Connection::fromDsn ($ dsn , $ options ), $ serializer ),
49
+ $ factory ->createTransport ($ dsn , $ options , $ serializer )
50
+ );
51
+ }
52
+
53
+ /**
54
+ * @return iterable<array{0: string, 1: array}>
55
+ */
56
+ public static function createProvider (): iterable
57
+ {
58
+ yield 'scheme "redis" without options ' => [
59
+ 'redis:// ' .getenv ('REDIS_HOST ' ),
60
+ [],
61
+ ];
62
+
63
+ yield 'scheme "rediss" without options ' => [
64
+ 'rediss:// ' .getenv ('REDIS_HOST ' ),
65
+ [],
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