File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ public static function create(ContainerInterface $container = null): App
3131 $ container ->set (CallableResolverInterface::class, new CallableResolver ($ callableResolver ));
3232 $ app = AppFactory::createFromContainer ($ container );
3333
34+ $ container ->set (App::class, $ app );
35+
3436 $ controllerInvoker = self ::createControllerInvoker ($ container );
3537 $ app ->getRouteCollector ()->setDefaultInvocationStrategy ($ controllerInvoker );
3638
Original file line number Diff line number Diff line change 55use DI \Bridge \Slim \Bridge ;
66use DI \Bridge \Slim \Test \Mock \RequestFactory ;
77use PHPUnit \Framework \TestCase ;
8+ use Slim \App ;
9+ use Psr \Http \Message \ResponseInterface ;
810
911class ApplicationTest extends TestCase
1012{
@@ -24,4 +26,23 @@ public function runs()
2426
2527 $ this ->assertTrue ($ called );
2628 }
29+
30+ /**
31+ * @test
32+ */
33+ public function register_app_instance_to_container ()
34+ {
35+ $ app = Bridge::create ();
36+
37+ $ instance = null ;
38+
39+ $ app ->get ('/ ' , function (App $ app , ResponseInterface $ response ) use (&$ instance ) {
40+ $ instance = $ app ;
41+ return $ response ;
42+ });
43+
44+ $ app ->handle (RequestFactory::create ());
45+
46+ $ this ->assertSame ($ app , $ instance );
47+ }
2748}
You can’t perform that action at this time.
0 commit comments