File tree 2 files changed +23
-0
lines changed
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
31
31
$ container ->set (CallableResolverInterface::class, new CallableResolver ($ callableResolver ));
32
32
$ app = AppFactory::createFromContainer ($ container );
33
33
34
+ $ container ->set (App::class, $ app );
35
+
34
36
$ controllerInvoker = self ::createControllerInvoker ($ container );
35
37
$ app ->getRouteCollector ()->setDefaultInvocationStrategy ($ controllerInvoker );
36
38
Original file line number Diff line number Diff line change 5
5
use DI \Bridge \Slim \Bridge ;
6
6
use DI \Bridge \Slim \Test \Mock \RequestFactory ;
7
7
use PHPUnit \Framework \TestCase ;
8
+ use Slim \App ;
9
+ use Psr \Http \Message \ResponseInterface ;
8
10
9
11
class ApplicationTest extends TestCase
10
12
{
@@ -24,4 +26,23 @@ public function runs()
24
26
25
27
$ this ->assertTrue ($ called );
26
28
}
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
+ }
27
48
}
You can’t perform that action at this time.
0 commit comments