@@ -50,63 +50,6 @@ protected function getInstance($options = [])
50
50
return new RedisHandler ($ sessionConfig , $ this ->userIpAddress );
51
51
}
52
52
53
- public function testSavePathWithoutProtocol (): void
54
- {
55
- $ handler = $ this ->getInstance (
56
- ['savePath ' => '127.0.0.1:6379 ' ]
57
- );
58
-
59
- $ savePath = $ this ->getPrivateProperty ($ handler , 'savePath ' );
60
-
61
- $ this ->assertSame ('tcp ' , $ savePath ['protocol ' ]);
62
- }
63
-
64
- public function testSavePathTLSAuth (): void
65
- {
66
- $ handler = $ this ->getInstance (
67
- ['savePath ' => 'tls://127.0.0.1:6379?auth=password ' ]
68
- );
69
-
70
- $ savePath = $ this ->getPrivateProperty ($ handler , 'savePath ' );
71
-
72
- $ this ->assertSame ('tls ' , $ savePath ['protocol ' ]);
73
- $ this ->assertSame ('password ' , $ savePath ['password ' ]);
74
- }
75
-
76
- public function testSavePathTCPAuth (): void
77
- {
78
- $ handler = $ this ->getInstance (
79
- ['savePath ' => 'tcp://127.0.0.1:6379?auth=password ' ]
80
- );
81
-
82
- $ savePath = $ this ->getPrivateProperty ($ handler , 'savePath ' );
83
-
84
- $ this ->assertSame ('tcp ' , $ savePath ['protocol ' ]);
85
- $ this ->assertSame ('password ' , $ savePath ['password ' ]);
86
- }
87
-
88
- public function testSavePathTimeoutFloat (): void
89
- {
90
- $ handler = $ this ->getInstance (
91
- ['savePath ' => 'tcp://127.0.0.1:6379?timeout=2.5 ' ]
92
- );
93
-
94
- $ savePath = $ this ->getPrivateProperty ($ handler , 'savePath ' );
95
-
96
- $ this ->assertEqualsWithDelta (2.5 , $ savePath ['timeout ' ], PHP_FLOAT_EPSILON );
97
- }
98
-
99
- public function testSavePathTimeoutInt (): void
100
- {
101
- $ handler = $ this ->getInstance (
102
- ['savePath ' => 'tcp://127.0.0.1:6379?timeout=10 ' ]
103
- );
104
-
105
- $ savePath = $ this ->getPrivateProperty ($ handler , 'savePath ' );
106
-
107
- $ this ->assertEqualsWithDelta (10.0 , $ savePath ['timeout ' ], PHP_FLOAT_EPSILON );
108
- }
109
-
110
53
public function testOpen (): void
111
54
{
112
55
$ handler = $ this ->getInstance ();
@@ -190,4 +133,73 @@ public function testSecondaryReadAfterClose(): void
190
133
191
134
$ handler ->close ();
192
135
}
136
+
137
+ /**
138
+ * @dataProvider provideSetSavePath
139
+ */
140
+ public function testSetSavePath (string $ savePath , array $ expected ): void
141
+ {
142
+ $ option = ['savePath ' => $ savePath ];
143
+ $ handler = $ this ->getInstance ($ option );
144
+
145
+ $ savePath = $ this ->getPrivateProperty ($ handler , 'savePath ' );
146
+
147
+ $ this ->assertSame ($ expected , $ savePath );
148
+ }
149
+
150
+ public static function provideSetSavePath (): iterable
151
+ {
152
+ yield from [
153
+ 'w/o protocol ' => [
154
+ '127.0.0.1:6379 ' ,
155
+ [
156
+ 'host ' => 'tcp://127.0.0.1 ' ,
157
+ 'port ' => 6379 ,
158
+ 'password ' => null ,
159
+ 'database ' => 0 ,
160
+ 'timeout ' => 0.0 ,
161
+ ],
162
+ ],
163
+ 'tls auth ' => [
164
+ 'tls://127.0.0.1:6379?auth=password ' ,
165
+ [
166
+ 'host ' => 'tls://127.0.0.1 ' ,
167
+ 'port ' => 6379 ,
168
+ 'password ' => 'password ' ,
169
+ 'database ' => 0 ,
170
+ 'timeout ' => 0.0 ,
171
+ ],
172
+ ],
173
+ 'tcp auth ' => [
174
+ 'tcp://127.0.0.1:6379?auth=password ' ,
175
+ [
176
+ 'host ' => 'tcp://127.0.0.1 ' ,
177
+ 'port ' => 6379 ,
178
+ 'password ' => 'password ' ,
179
+ 'database ' => 0 ,
180
+ 'timeout ' => 0.0 ,
181
+ ],
182
+ ],
183
+ 'timeout float ' => [
184
+ 'tcp://127.0.0.1:6379?timeout=2.5 ' ,
185
+ [
186
+ 'host ' => 'tcp://127.0.0.1 ' ,
187
+ 'port ' => 6379 ,
188
+ 'password ' => null ,
189
+ 'database ' => 0 ,
190
+ 'timeout ' => 2.5 ,
191
+ ],
192
+ ],
193
+ 'timeout int ' => [
194
+ 'tcp://127.0.0.1:6379?timeout=10 ' ,
195
+ [
196
+ 'host ' => 'tcp://127.0.0.1 ' ,
197
+ 'port ' => 6379 ,
198
+ 'password ' => null ,
199
+ 'database ' => 0 ,
200
+ 'timeout ' => 10.0 ,
201
+ ],
202
+ ],
203
+ ];
204
+ }
193
205
}
0 commit comments