Skip to content

Commit e168fa1

Browse files
ddevsrpaulbalandan
authored andcommitted
tests: persistent connection session redis
fix: test persistent parameter false
1 parent 629eb5f commit e168fa1

File tree

2 files changed

+71
-41
lines changed

2 files changed

+71
-41
lines changed

system/Session/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function setSavePath(): void
142142
}
143143
}
144144

145-
$persistent = $query['persistent'] ?? null;
145+
$persistent = isset($query['persistent']) ? (bool) $query['persistent'] : null;
146146
$password = $query['auth'] ?? null;
147147
$database = isset($query['database']) ? (int) $query['database'] : 0;
148148
$timeout = isset($query['timeout']) ? (float) $query['timeout'] : 0.0;

tests/system/Session/Handlers/Database/RedisHandlerTest.php

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -163,81 +163,111 @@ public static function provideSetSavePath(): iterable
163163
'w/o protocol' => [
164164
'127.0.0.1:6379',
165165
[
166-
'host' => 'tcp://127.0.0.1',
167-
'port' => 6379,
168-
'password' => null,
169-
'database' => 0,
170-
'timeout' => 0.0,
166+
'host' => 'tcp://127.0.0.1',
167+
'port' => 6379,
168+
'password' => null,
169+
'database' => 0,
170+
'timeout' => 0.0,
171+
'persistent' => null,
171172
],
172173
],
173174
'tls auth' => [
174175
'tls://127.0.0.1:6379?auth=password',
175176
[
176-
'host' => 'tls://127.0.0.1',
177-
'port' => 6379,
178-
'password' => 'password',
179-
'database' => 0,
180-
'timeout' => 0.0,
177+
'host' => 'tls://127.0.0.1',
178+
'port' => 6379,
179+
'password' => 'password',
180+
'database' => 0,
181+
'timeout' => 0.0,
182+
'persistent' => null,
181183
],
182184
],
183185
'tcp auth' => [
184186
'tcp://127.0.0.1:6379?auth=password',
185187
[
186-
'host' => 'tcp://127.0.0.1',
187-
'port' => 6379,
188-
'password' => 'password',
189-
'database' => 0,
190-
'timeout' => 0.0,
188+
'host' => 'tcp://127.0.0.1',
189+
'port' => 6379,
190+
'password' => 'password',
191+
'database' => 0,
192+
'timeout' => 0.0,
193+
'persistent' => null,
191194
],
192195
],
193196
'timeout float' => [
194197
'tcp://127.0.0.1:6379?timeout=2.5',
195198
[
196-
'host' => 'tcp://127.0.0.1',
197-
'port' => 6379,
198-
'password' => null,
199-
'database' => 0,
200-
'timeout' => 2.5,
199+
'host' => 'tcp://127.0.0.1',
200+
'port' => 6379,
201+
'password' => null,
202+
'database' => 0,
203+
'timeout' => 2.5,
204+
'persistent' => null,
201205
],
202206
],
203207
'timeout int' => [
204208
'tcp://127.0.0.1:6379?timeout=10',
205209
[
206-
'host' => 'tcp://127.0.0.1',
207-
'port' => 6379,
208-
'password' => null,
209-
'database' => 0,
210-
'timeout' => 10.0,
210+
'host' => 'tcp://127.0.0.1',
211+
'port' => 6379,
212+
'password' => null,
213+
'database' => 0,
214+
'timeout' => 10.0,
215+
'persistent' => null,
211216
],
212217
],
213218
'auth acl' => [
214219
'tcp://localhost:6379?auth[user]=redis-admin&auth[pass]=admin-password',
215220
[
216-
'host' => 'tcp://localhost',
217-
'port' => 6379,
218-
'password' => ['user' => 'redis-admin', 'pass' => 'admin-password'],
219-
'database' => 0,
220-
'timeout' => 0.0,
221+
'host' => 'tcp://localhost',
222+
'port' => 6379,
223+
'password' => ['user' => 'redis-admin', 'pass' => 'admin-password'],
224+
'database' => 0,
225+
'timeout' => 0.0,
226+
'persistent' => null,
221227
],
222228
],
223229
'unix domain socket' => [
224230
'unix:///tmp/redis.sock',
225231
[
226-
'host' => '/tmp/redis.sock',
227-
'port' => 0,
228-
'password' => null,
229-
'database' => 0,
230-
'timeout' => 0.0,
232+
'host' => '/tmp/redis.sock',
233+
'port' => 0,
234+
'password' => null,
235+
'database' => 0,
236+
'timeout' => 0.0,
237+
'persistent' => null,
231238
],
232239
],
233240
'unix domain socket w/o protocol' => [
234241
'/tmp/redis.sock',
235242
[
236-
'host' => '/tmp/redis.sock',
237-
'port' => 0,
238-
'password' => null,
239-
'database' => 0,
240-
'timeout' => 0.0,
243+
'host' => '/tmp/redis.sock',
244+
'port' => 0,
245+
'password' => null,
246+
'database' => 0,
247+
'timeout' => 0.0,
248+
'persistent' => null,
249+
],
250+
],
251+
'persistent connection' => [
252+
'tcp://127.0.0.1:6379?timeout=10&persistent=1',
253+
[
254+
'host' => 'tcp://127.0.0.1',
255+
'port' => 6379,
256+
'password' => null,
257+
'database' => 0,
258+
'timeout' => 10.0,
259+
'persistent' => true,
260+
],
261+
],
262+
'no persistent connection with have parameter' => [
263+
'tcp://127.0.0.1:6379?timeout=10&persistent=0',
264+
[
265+
'host' => 'tcp://127.0.0.1',
266+
'port' => 6379,
267+
'password' => null,
268+
'database' => 0,
269+
'timeout' => 10.0,
270+
'persistent' => false,
241271
],
242272
],
243273
];

0 commit comments

Comments
 (0)