File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,12 @@ public static function create(array $options)
103103 }
104104
105105 $ configuration = new Configuration ();
106- $ configuration ->userData = \array_fill_keys (\array_keys ($ options ), true );
106+ $ configuration ->userData = [];
107+ foreach ($ options as $ key => $ value ) {
108+ if (null !== $ value ) {
109+ $ configuration ->userData [$ key ] = true ;
110+ }
111+ }
107112
108113 foreach (self ::DEFAULT_OPTIONS as $ optionTrigger => $ defaultValue ) {
109114 if (isset ($ options [$ optionTrigger ])) {
Original file line number Diff line number Diff line change @@ -38,6 +38,29 @@ public function testIsDefault()
3838 self ::assertFalse ($ config ->isDefault ('region ' ));
3939 }
4040
41+ /**
42+ * Make sure passing "null" is the same as no passing anything.
43+ */
44+ public function testIsDefaultWhenPassingNull ()
45+ {
46+ $ config = Configuration::create ([
47+ 'region ' => null ,
48+ 'accessKeyId ' => null ,
49+ 'accessKeySecret ' => null ,
50+ ]);
51+
52+ self ::assertFalse ($ config ->has ('accessKeyId ' ));
53+ self ::assertFalse ($ config ->has ('accessKeySecret ' ));
54+
55+ self ::assertTrue ($ config ->isDefault ('region ' ));
56+ self ::assertTrue ($ config ->isDefault ('accessKeyId ' ));
57+ self ::assertTrue ($ config ->isDefault ('accessKeySecret ' ));
58+
59+ self ::assertEquals (Configuration::DEFAULT_REGION , $ config ->get ('region ' ));
60+ self ::assertNull ($ config ->get ('accessKeyId ' ));
61+ self ::assertNull ($ config ->get ('accessKeySecret ' ));
62+ }
63+
4164 public function provideConfiguration (): iterable
4265 {
4366 yield 'simple config ' => [['endpoint ' => 'foo ' ], [], ['endpoint ' => 'foo ' ]];
You can’t perform that action at this time.
0 commit comments