@@ -215,7 +215,7 @@ public function testGetFactory()
215215 $ this ->assertNotSame ($ container ->factory ("closure " ), $ container ->factory ("closure " ));
216216 }
217217
218- public function testOverriding ()
218+ public function testOverridingValueWithValue ()
219219 {
220220 $ container = new Container ();
221221 $ container ->set ("param " , "value " );
@@ -224,6 +224,41 @@ public function testOverriding()
224224 $ this ->assertSame ("other value " , $ container ->get ("param " ));
225225 }
226226
227+ public function testOverridingClosureWithValue ()
228+ {
229+ $ container = new Container ();
230+ $ container ->set ("random " , function () {
231+ return rand (1 , 9 );
232+ });
233+ $ this ->assertInternalType ("int " , $ container ->get ("random " ));
234+ $ container ->set ("random " , "a " );
235+ $ this ->assertSame ("a " , $ container ->get ("random " ));
236+ }
237+
238+ public function testOverridingValueWithClosure ()
239+ {
240+ $ container = new Container ();
241+ $ container ->set ("random " , "a " );
242+ $ this ->assertSame ("a " , $ container ->get ("random " ));
243+ $ container ->set ("random " , function () {
244+ return rand (1 , 9 );
245+ });
246+ $ this ->assertInternalType ("int " , $ container ->get ("random " ));
247+ }
248+
249+ public function testOverridingClosureWithClosure ()
250+ {
251+ $ container = new Container ();
252+ $ container ->set ("random " , function () {
253+ return rand (1 , 9 );
254+ });
255+ $ this ->assertInternalType ("int " , $ container ->get ("random " ));
256+ $ container ->set ("random " , function () {
257+ return "pi= " . (3 + 0.14 );
258+ });
259+ $ this ->assertSame ("pi=3.14 " , $ container ->get ("random " ));
260+ }
261+
227262 public function testOverridingLockedValue ()
228263 {
229264 $ container = new Container ();
0 commit comments