File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-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 DI \ContainerBuilder ;
9
+ use Slim \App ;
10
+ use Psr \Http \Message \ResponseInterface ;
8
11
9
12
class ApplicationTest extends TestCase
10
13
{
@@ -24,4 +27,26 @@ public function runs()
24
27
25
28
$ this ->assertTrue ($ called );
26
29
}
30
+
31
+ /**
32
+ * @test
33
+ */
34
+ public function register_app_instance_to_container ()
35
+ {
36
+ $ app = Bridge::create ();
37
+
38
+ $ instance = null ;
39
+
40
+ $ app ->get ('/ ' , function (App $ app , ResponseInterface $ response ) use (&$ instance ) {
41
+ $ instance = $ app ;
42
+ return $ response ;
43
+ });
44
+
45
+ $ app ->handle (RequestFactory::create ());
46
+
47
+ $ this ->assertInstanceOf (
48
+ App::class,
49
+ $ instance
50
+ );
51
+ }
27
52
}
You can’t perform that action at this time.
0 commit comments