Skip to content

Commit 59fe543

Browse files
committed
tests: persistent connection session redis
1 parent 45638a3 commit 59fe543

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
@@ -154,81 +154,111 @@ public static function provideSetSavePath(): iterable
154154
'w/o protocol' => [
155155
'127.0.0.1:6379',
156156
[
157-
'host' => 'tcp://127.0.0.1',
158-
'port' => 6379,
159-
'password' => null,
160-
'database' => 0,
161-
'timeout' => 0.0,
157+
'host' => 'tcp://127.0.0.1',
158+
'port' => 6379,
159+
'password' => null,
160+
'database' => 0,
161+
'timeout' => 0.0,
162+
'persistent' => null,
162163
],
163164
],
164165
'tls auth' => [
165166
'tls://127.0.0.1:6379?auth=password',
166167
[
167-
'host' => 'tls://127.0.0.1',
168-
'port' => 6379,
169-
'password' => 'password',
170-
'database' => 0,
171-
'timeout' => 0.0,
168+
'host' => 'tls://127.0.0.1',
169+
'port' => 6379,
170+
'password' => 'password',
171+
'database' => 0,
172+
'timeout' => 0.0,
173+
'persistent' => null,
172174
],
173175
],
174176
'tcp auth' => [
175177
'tcp://127.0.0.1:6379?auth=password',
176178
[
177-
'host' => 'tcp://127.0.0.1',
178-
'port' => 6379,
179-
'password' => 'password',
180-
'database' => 0,
181-
'timeout' => 0.0,
179+
'host' => 'tcp://127.0.0.1',
180+
'port' => 6379,
181+
'password' => 'password',
182+
'database' => 0,
183+
'timeout' => 0.0,
184+
'persistent' => null,
182185
],
183186
],
184187
'timeout float' => [
185188
'tcp://127.0.0.1:6379?timeout=2.5',
186189
[
187-
'host' => 'tcp://127.0.0.1',
188-
'port' => 6379,
189-
'password' => null,
190-
'database' => 0,
191-
'timeout' => 2.5,
190+
'host' => 'tcp://127.0.0.1',
191+
'port' => 6379,
192+
'password' => null,
193+
'database' => 0,
194+
'timeout' => 2.5,
195+
'persistent' => null,
192196
],
193197
],
194198
'timeout int' => [
195199
'tcp://127.0.0.1:6379?timeout=10',
196200
[
197-
'host' => 'tcp://127.0.0.1',
198-
'port' => 6379,
199-
'password' => null,
200-
'database' => 0,
201-
'timeout' => 10.0,
201+
'host' => 'tcp://127.0.0.1',
202+
'port' => 6379,
203+
'password' => null,
204+
'database' => 0,
205+
'timeout' => 10.0,
206+
'persistent' => null,
202207
],
203208
],
204209
'auth acl' => [
205210
'tcp://localhost:6379?auth[user]=redis-admin&auth[pass]=admin-password',
206211
[
207-
'host' => 'tcp://localhost',
208-
'port' => 6379,
209-
'password' => ['user' => 'redis-admin', 'pass' => 'admin-password'],
210-
'database' => 0,
211-
'timeout' => 0.0,
212+
'host' => 'tcp://localhost',
213+
'port' => 6379,
214+
'password' => ['user' => 'redis-admin', 'pass' => 'admin-password'],
215+
'database' => 0,
216+
'timeout' => 0.0,
217+
'persistent' => null,
212218
],
213219
],
214220
'unix domain socket' => [
215221
'unix:///tmp/redis.sock',
216222
[
217-
'host' => '/tmp/redis.sock',
218-
'port' => 0,
219-
'password' => null,
220-
'database' => 0,
221-
'timeout' => 0.0,
223+
'host' => '/tmp/redis.sock',
224+
'port' => 0,
225+
'password' => null,
226+
'database' => 0,
227+
'timeout' => 0.0,
228+
'persistent' => null,
222229
],
223230
],
224231
'unix domain socket w/o protocol' => [
225232
'/tmp/redis.sock',
226233
[
227-
'host' => '/tmp/redis.sock',
228-
'port' => 0,
229-
'password' => null,
230-
'database' => 0,
231-
'timeout' => 0.0,
234+
'host' => '/tmp/redis.sock',
235+
'port' => 0,
236+
'password' => null,
237+
'database' => 0,
238+
'timeout' => 0.0,
239+
'persistent' => null,
240+
],
241+
],
242+
'persistent connection' => [
243+
'tcp://127.0.0.1:6379?timeout=10&persistent=1',
244+
[
245+
'host' => 'tcp://127.0.0.1',
246+
'port' => 6379,
247+
'password' => null,
248+
'database' => 0,
249+
'timeout' => 10.0,
250+
'persistent' => true,
251+
],
252+
],
253+
'no persistent connection with have parameter' => [
254+
'tcp://127.0.0.1:6379?timeout=10&persistent=0',
255+
[
256+
'host' => 'tcp://127.0.0.1',
257+
'port' => 6379,
258+
'password' => null,
259+
'database' => 0,
260+
'timeout' => 10.0,
261+
'persistent' => null,
232262
],
233263
],
234264
];

0 commit comments

Comments
 (0)