Skip to content

Commit ffb4340

Browse files
committed
[redis] add test, fix tests.
1 parent b703991 commit ffb4340

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

RedisConnectionFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ private function defaultConfig(): array
152152
{
153153
return [
154154
'host' => 'localhost',
155+
'scheme' => 'redis',
155156
'port' => 6379,
156157
'timeout' => .0,
157158
'reserved' => null,

Tests/RedisConnectionFactoryConfigTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testThrowNeitherArrayStringNorNullGivenAsConfig()
2525
public function testThrowIfSchemeIsNotAmqp()
2626
{
2727
$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:".');
2929

3030
new RedisConnectionFactory('http://example.com');
3131
}
@@ -57,6 +57,15 @@ public function testCouldBeCreatedWithRedisInstance()
5757
$this->assertSame($redisMock, $context->getRedis());
5858
}
5959

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+
6069
/**
6170
* @dataProvider provideConfigs
6271
*
@@ -76,6 +85,7 @@ public static function provideConfigs()
7685
null,
7786
[
7887
'host' => 'localhost',
88+
'scheme' => 'redis',
7989
'port' => 6379,
8090
'timeout' => null,
8191
'reserved' => null,
@@ -92,6 +102,7 @@ public static function provideConfigs()
92102
'redis:',
93103
[
94104
'host' => 'localhost',
105+
'scheme' => 'redis',
95106
'port' => 6379,
96107
'timeout' => null,
97108
'reserved' => null,
@@ -108,6 +119,7 @@ public static function provideConfigs()
108119
[],
109120
[
110121
'host' => 'localhost',
122+
'scheme' => 'redis',
111123
'port' => 6379,
112124
'timeout' => null,
113125
'reserved' => null,
@@ -124,6 +136,7 @@ public static function provideConfigs()
124136
'redis://localhost:1234?foo=bar&lazy=0&persisted=true&database=5',
125137
[
126138
'host' => 'localhost',
139+
'scheme' => 'redis',
127140
'port' => 1234,
128141
'timeout' => null,
129142
'reserved' => null,
@@ -142,6 +155,7 @@ public static function provideConfigs()
142155
'redis://localhost:1234?foo=bar&lazy=0&vendor=predis',
143156
[
144157
'host' => 'localhost',
158+
'scheme' => 'redis',
145159
'port' => 1234,
146160
'timeout' => null,
147161
'reserved' => null,
@@ -151,7 +165,6 @@ public static function provideConfigs()
151165
'lazy' => false,
152166
'foo' => 'bar',
153167
'database' => 0,
154-
'scheme' => 'redis',
155168
'redis' => null,
156169
],
157170
];
@@ -161,6 +174,7 @@ public static function provideConfigs()
161174
'rediss://localhost:1234?foo=bar&lazy=0&vendor=predis',
162175
[
163176
'host' => 'localhost',
177+
'scheme' => 'rediss',
164178
'port' => 1234,
165179
'timeout' => null,
166180
'reserved' => null,
@@ -170,17 +184,15 @@ public static function provideConfigs()
170184
'lazy' => false,
171185
'foo' => 'bar',
172186
'database' => 0,
173-
'scheme' => 'rediss',
174187
'redis' => null,
175188
],
176189
];
177190

178-
179-
180191
yield [
181192
['host' => 'localhost', 'port' => 1234, 'foo' => 'bar'],
182193
[
183194
'host' => 'localhost',
195+
'scheme' => 'redis',
184196
'port' => 1234,
185197
'timeout' => null,
186198
'reserved' => null,
@@ -199,6 +211,7 @@ public static function provideConfigs()
199211
'redis://h:asdfqwer1234asdf@ec2-111-1-1-1.compute-1.amazonaws.com:111',
200212
[
201213
'host' => 'ec2-111-1-1-1.compute-1.amazonaws.com',
214+
'scheme' => 'redis',
202215
'port' => 111,
203216
'timeout' => null,
204217
'reserved' => null,

0 commit comments

Comments
 (0)