14
14
15
15
class PredisParametersFactoryTest extends TestCase
16
16
{
17
- /** @return array<array{0: string, 1: class-string, 2: array<string, mixed>, 3 : array<string, mixed>}> */
17
+ /** @return array<array{0: string, 1: array<string, mixed>, 2 : array<string, mixed>}> */
18
18
public static function createDp (): array
19
19
{
20
20
return [
21
21
[
22
22
'redis://z:df577d779b4f724c8c29b5eff5bcc534b732722b9df308a661f1b79014175063d5@ec2-34-321-123-45.us-east-1.compute.amazonaws.com:3210 ' ,
23
- Parameters::class,
24
23
[
25
24
'test ' => 123 ,
26
25
'some ' => 'string ' ,
@@ -48,7 +47,6 @@ public static function createDp(): array
48
47
],
49
48
[
50
49
'redis://pw@/var/run/redis/redis-1.sock/10 ' ,
51
- Parameters::class,
52
50
[
53
51
'test ' => 124 ,
54
52
'password ' => 'toto ' ,
@@ -72,7 +70,6 @@ public static function createDp(): array
72
70
],
73
71
[
74
72
'rediss://pw@localhost:6380 ' ,
75
- Parameters::class,
76
73
[],
77
74
[
78
75
'scheme ' => 'tls ' ,
@@ -83,7 +80,6 @@ public static function createDp(): array
83
80
],
84
81
[
85
82
'redis://localhost?alias=master ' ,
86
- Parameters::class,
87
83
['replication ' => 'predis ' ],
88
84
[
89
85
'scheme ' => 'tcp ' ,
@@ -98,7 +94,6 @@ public static function createDp(): array
98
94
],
99
95
[
100
96
'redis://localhost?alias=connection_alias ' ,
101
- Parameters::class,
102
97
[
103
98
'replication ' => 'predis ' ,
104
99
'alias ' => 'client_alias ' ,
@@ -116,23 +111,35 @@ public static function createDp(): array
116
111
],
117
112
[
118
113
'redis://localhost/0 ' ,
119
- Parameters::class,
120
114
['persistent ' => true ],
121
115
[
122
116
'persistent ' => true ,
123
117
'database ' => 0 ,
124
118
],
125
119
],
126
-
127
120
[
128
121
'redis://localhost ' ,
129
- Parameters::class,
130
122
['database ' => 11 , 'password ' => 'pass ' ],
131
123
[
132
124
'database ' => 11 ,
133
125
'password ' => 'pass ' ,
134
126
],
135
127
],
128
+ 'everything in DSN ' => [
129
+ 'rediss://pw@localhost:6380/0?prefix=foo&alias=connection_alias ' ,
130
+ [],
131
+ $ allOptions =
132
+ [
133
+ 'scheme ' => 'tls ' ,
134
+ 'host ' => 'localhost ' ,
135
+ 'port ' => 6380 ,
136
+ 'password ' => 'pw ' ,
137
+ 'database ' => 0 ,
138
+ 'prefix ' => 'foo ' ,
139
+ 'alias ' => 'connection_alias ' ,
140
+ ],
141
+ ],
142
+ 'everything in options ' => ['rediss://localhost:6380 ' , $ allOptions , $ allOptions ],
136
143
];
137
144
}
138
145
@@ -142,11 +149,9 @@ public static function createDp(): array
142
149
*
143
150
* @dataProvider createDp
144
151
*/
145
- public function testCreate (string $ dsn , string $ class , array $ options , array $ expectedParameters ): void
152
+ public function testCreate (string $ dsn , array $ options , array $ expectedParameters ): void
146
153
{
147
- $ parameters = PredisParametersFactory::create ($ options , $ class , $ dsn );
148
-
149
- $ this ->assertInstanceOf ($ class , $ parameters );
154
+ $ parameters = PredisParametersFactory::create ($ options , Parameters::class, $ dsn );
150
155
151
156
foreach ($ expectedParameters as $ name => $ value ) {
152
157
$ this ->assertSame ($ value , $ parameters ->{$ name }, sprintf ("Wrong '%s' value " , $ name ));
@@ -157,6 +162,7 @@ public function testCreateException(): void
157
162
{
158
163
$ this ->expectException (InvalidArgumentException::class);
159
164
165
+ /** @psalm-suppress InvalidArgument */
160
166
PredisParametersFactory::create ([], stdClass::class, 'redis://localhost ' );
161
167
}
162
168
}
0 commit comments