@@ -25,7 +25,7 @@ public function testThrowNeitherArrayStringNorNullGivenAsConfig()
25
25
public function testThrowIfSchemeIsNotAmqp ()
26
26
{
27
27
$ this ->expectException (\LogicException::class);
28
- $ this ->expectExceptionMessage ('The given DSN "http://example.com" is not supported. Must start with "redis:". ' );
28
+ $ this ->expectExceptionMessage ('The given DSN "http://example.com" is not supported. Must start with "redis:" or "rediss:" . ' );
29
29
30
30
new RedisConnectionFactory ('http://example.com ' );
31
31
}
@@ -57,6 +57,15 @@ public function testCouldBeCreatedWithRedisInstance()
57
57
$ this ->assertSame ($ redisMock , $ context ->getRedis ());
58
58
}
59
59
60
+ public function testThrowIfRedissConnectionUsedWithPhpRedisExtension ()
61
+ {
62
+ $ factory = new RedisConnectionFactory ('rediss:?vendor=phpredis ' );
63
+
64
+ $ this ->expectException (\LogicException::class);
65
+ $ this ->expectExceptionMessage ('The phpredis extension does not support secured connections. Try to use predis library as vendor. ' );
66
+ $ factory ->createContext ();
67
+ }
68
+
60
69
/**
61
70
* @dataProvider provideConfigs
62
71
*
@@ -76,6 +85,7 @@ public static function provideConfigs()
76
85
null ,
77
86
[
78
87
'host ' => 'localhost ' ,
88
+ 'scheme ' => 'redis ' ,
79
89
'port ' => 6379 ,
80
90
'timeout ' => null ,
81
91
'reserved ' => null ,
@@ -92,6 +102,7 @@ public static function provideConfigs()
92
102
'redis: ' ,
93
103
[
94
104
'host ' => 'localhost ' ,
105
+ 'scheme ' => 'redis ' ,
95
106
'port ' => 6379 ,
96
107
'timeout ' => null ,
97
108
'reserved ' => null ,
@@ -108,6 +119,7 @@ public static function provideConfigs()
108
119
[],
109
120
[
110
121
'host ' => 'localhost ' ,
122
+ 'scheme ' => 'redis ' ,
111
123
'port ' => 6379 ,
112
124
'timeout ' => null ,
113
125
'reserved ' => null ,
@@ -124,6 +136,7 @@ public static function provideConfigs()
124
136
'redis://localhost:1234?foo=bar&lazy=0&persisted=true&database=5 ' ,
125
137
[
126
138
'host ' => 'localhost ' ,
139
+ 'scheme ' => 'redis ' ,
127
140
'port ' => 1234 ,
128
141
'timeout ' => null ,
129
142
'reserved ' => null ,
@@ -137,10 +150,49 @@ public static function provideConfigs()
137
150
],
138
151
];
139
152
153
+ //check normal redis connection for predis library
154
+ yield [
155
+ 'redis://localhost:1234?foo=bar&lazy=0&vendor=predis ' ,
156
+ [
157
+ 'host ' => 'localhost ' ,
158
+ 'scheme ' => 'redis ' ,
159
+ 'port ' => 1234 ,
160
+ 'timeout ' => null ,
161
+ 'reserved ' => null ,
162
+ 'retry_interval ' => null ,
163
+ 'vendor ' => 'predis ' ,
164
+ 'persisted ' => false ,
165
+ 'lazy ' => false ,
166
+ 'foo ' => 'bar ' ,
167
+ 'database ' => 0 ,
168
+ 'redis ' => null ,
169
+ ],
170
+ ];
171
+
172
+ //check tls connection for predis library
173
+ yield [
174
+ 'rediss://localhost:1234?foo=bar&lazy=0&vendor=predis ' ,
175
+ [
176
+ 'host ' => 'localhost ' ,
177
+ 'scheme ' => 'rediss ' ,
178
+ 'port ' => 1234 ,
179
+ 'timeout ' => null ,
180
+ 'reserved ' => null ,
181
+ 'retry_interval ' => null ,
182
+ 'vendor ' => 'predis ' ,
183
+ 'persisted ' => false ,
184
+ 'lazy ' => false ,
185
+ 'foo ' => 'bar ' ,
186
+ 'database ' => 0 ,
187
+ 'redis ' => null ,
188
+ ],
189
+ ];
190
+
140
191
yield [
141
192
['host ' => 'localhost ' , 'port ' => 1234 , 'foo ' => 'bar ' ],
142
193
[
143
194
'host ' => 'localhost ' ,
195
+ 'scheme ' => 'redis ' ,
144
196
'port ' => 1234 ,
145
197
'timeout ' => null ,
146
198
'reserved ' => null ,
@@ -159,6 +211,7 @@ public static function provideConfigs()
159
211
'redis://h:asdfqwer1234asdf@ec2-111-1-1-1.compute-1.amazonaws.com:111 ' ,
160
212
[
161
213
'host ' => 'ec2-111-1-1-1.compute-1.amazonaws.com ' ,
214
+ 'scheme ' => 'redis ' ,
162
215
'port ' => 111 ,
163
216
'timeout ' => null ,
164
217
'reserved ' => null ,
0 commit comments