@@ -211,7 +211,8 @@ public function testProvidedContainer()
211211
212212 $ cli = new CLI (new Generic (), ['test.php ' , 'build ' ], $ container );
213213
214- $ this ->assertSame ($ container , $ cli ->getContainer ());
214+ $ this ->assertNotSame ($ container , $ cli ->getContainer ());
215+ $ this ->assertEquals ('test-value ' , $ cli ->getResource ('test ' ));
215216
216217 $ cli ->task ('build ' )
217218 ->inject ('test ' )
@@ -226,6 +227,25 @@ public function testProvidedContainer()
226227 $ this ->assertEquals ('test-value ' , $ result );
227228 }
228229
230+ public function testResetPreservesInjectedContainer ()
231+ {
232+ $ container = new Container ();
233+ $ container ->set ('base ' , fn () => 'base-value ' );
234+
235+ $ cli = new CLI (new Generic (), ['test.php ' , 'build ' ], $ container );
236+ $ cli ->setResource ('runtime ' , fn () => 'runtime-value ' );
237+
238+ $ this ->assertEquals ('base-value ' , $ cli ->getResource ('base ' ));
239+ $ this ->assertEquals ('runtime-value ' , $ cli ->getResource ('runtime ' ));
240+
241+ $ cli ->reset ();
242+
243+ $ this ->assertEquals ('base-value ' , $ cli ->getResource ('base ' ));
244+
245+ $ this ->expectException (\Exception::class);
246+ $ cli ->getResource ('runtime ' );
247+ }
248+
229249 public function testMatch ()
230250 {
231251 $ cli = new CLI (new Generic (), ['test.php ' , 'build2 ' , '--email=me@example.com ' , '--list=item1 ' , '--list=item2 ' ]); // Mock command request
0 commit comments