@@ -30,7 +30,7 @@ class DispatcherTest extends TestCase
3030    /** 
3131     * @return void 
3232     */ 
33-     public  function  testDispatching (): void 
33+     public  function  testDispatchingCallableHandler (): void 
3434    {
3535        $ container  = $ this  ->getMockBuilder (ContainerInterface::class)
3636            ->getMock ();
@@ -46,5 +46,52 @@ public function testDispatching(): void
4646        $ dispatcher  = new  Dispatcher ($ container );
4747        $ result  = $ dispatcher ->dispatch ($ request , $ callable );
4848        $ this  ->assertInstanceOf (ResponseInterface::class, $ result );
49+ 
50+         new  class  {
51+             public  function  log ($ msg )
52+             {
53+                 echo  $ msg ;
54+             }
55+         };
56+     }
57+ 
58+     /** 
59+      * @return void 
60+      */ 
61+     public  function  testDispatchingClassString (): void 
62+     {
63+         $ container  = $ this  ->getMockBuilder (ContainerInterface::class)
64+             ->getMock ();
65+         $ request  = $ this  ->getMockBuilder (ServerRequestInterface::class)
66+             ->getMock ();
67+         $ response  = $ this  ->getMockBuilder (ResponseInterface::class)
68+             ->getMock ();
69+ 
70+         $ class  = new  class ($ response ) {
71+             protected  $ response ;
72+             public  function  __construct (ResponseInterface   $ response )
73+             {
74+                 $ this  ->response  = $ response ;
75+             }
76+ 
77+             public  function  login (ServerRequestInterface   $ request )
78+             {
79+                 return  $ this  ->response ;
80+             }
81+         };
82+ 
83+         $ container ->expects ($ this  ->any ())
84+             ->method ('has ' )
85+             ->with ('Users ' )
86+             ->willReturn (true );
87+ 
88+         $ container ->expects ($ this  ->any ())
89+             ->method ('get ' )
90+             ->with ('Users ' )
91+             ->willReturn ($ class );
92+ 
93+         $ dispatcher  = new  Dispatcher ($ container );
94+         $ result  = $ dispatcher ->dispatch ($ request , 'Users@login ' );
95+         $ this  ->assertInstanceOf (ResponseInterface::class, $ result );
4996    }
5097}
0 commit comments