@@ -208,28 +208,37 @@ public function getOptionProvider(): iterable
208
208
];
209
209
}
210
210
211
- public function testGetRequiredOptionGetsOptionIfSet ()
211
+ /**
212
+ * @dataProvider getRequiredOptionProvider
213
+ */
214
+ public function testGetRequiredOption (string $ expectedValue , string $ options , string $ option )
212
215
{
213
- $ options = ['with_value ' => 'some value ' ];
214
- $ dsn = new Dsn ('scheme ' , 'localhost ' , 'u$er ' , 'pa$s ' , '8000 ' , $ options , '/channel ' );
216
+ $ dsn = Dsn::fromString (sprintf ('scheme://localhost?%s ' , $ options ));
215
217
216
- $ this ->assertSame (' some value ' , $ dsn ->getRequiredOption (' with_value ' ));
218
+ $ this ->assertSame ($ expectedValue , $ dsn ->getRequiredOption ($ option ));
217
219
}
218
220
219
- public function testGetRequiredOptionGetsOptionIfValueIsZero ()
221
+ public function getRequiredOptionProvider (): iterable
220
222
{
221
- $ options = ['timeout ' => 0 ];
222
- $ dsn = new Dsn ('scheme ' , 'localhost ' , 'u$er ' , 'pa$s ' , '8000 ' , $ options , '/channel ' );
223
+ yield [
224
+ 'value ' ,
225
+ 'with_value=value ' ,
226
+ 'with_value '
227
+ ];
223
228
224
- $ this ->assertSame (0 , $ dsn ->getRequiredOption ('timeout ' ));
229
+ yield [
230
+ '0 ' ,
231
+ 'timeout=0 ' ,
232
+ 'timeout '
233
+ ];
225
234
}
226
235
227
236
/**
228
237
* @dataProvider getRequiredOptionThrowsMissingRequiredOptionExceptionProvider
229
238
*/
230
- public function testGetRequiredOptionThrowsMissingRequiredOptionException (string $ expectedExceptionMessage , array $ options , string $ option )
239
+ public function testGetRequiredOptionThrowsMissingRequiredOptionException (string $ expectedExceptionMessage , string $ options , string $ option )
231
240
{
232
- $ dsn = new Dsn ( 'scheme ' , ' localhost ' , ' u$er ' , ' pa$ s ' , ' 8000 ' , $ options, ' /channel ' );
241
+ $ dsn = Dsn:: fromString ( sprintf ( 'scheme:// localhost?% s ' , $ options) );
233
242
234
243
$ this ->expectException (MissingRequiredOptionException::class);
235
244
$ this ->expectExceptionMessage ($ expectedExceptionMessage );
@@ -241,20 +250,14 @@ public function getRequiredOptionThrowsMissingRequiredOptionExceptionProvider():
241
250
{
242
251
yield [
243
252
'The option "foo_bar" is required but missing. ' ,
244
- [ 'with_value ' => ' some value '] ,
253
+ 'with_value= value ' ,
245
254
'foo_bar ' ,
246
255
];
247
256
248
257
yield [
249
258
'The option "with_empty_string" is required but missing. ' ,
250
- [ 'with_empty_string ' => '' ] ,
259
+ 'with_empty_string= ' ,
251
260
'with_empty_string ' ,
252
261
];
253
-
254
- yield [
255
- 'The option "with_null" is required but missing. ' ,
256
- ['with_null ' => null ],
257
- 'with_null ' ,
258
- ];
259
262
}
260
263
}
0 commit comments