@@ -24,17 +24,18 @@ public function testLaravelMiddlewareIsHandledForInternalRequestsAndAuthenticate
2424 {
2525 $ response = new Response ;
2626 $ app = m::mock ('Symfony\Component\HttpKernel\HttpKernelInterface ' );
27- $ middleware = new Authentication ($ app );
27+ $ container = m::mock ('Illuminate\Container\Container ' );
28+ $ middleware = new Authentication ($ app , $ container );
2829 $ request = InternalRequest::create ('/ ' , 'GET ' );
2930
30- $ app ->shouldReceive ('boot ' )->once ();
31+ $ container ->shouldReceive ('boot ' )->once ();
3132 $ app ->shouldReceive ('handle ' )->once ()->with ($ request , HttpKernelInterface::MASTER_REQUEST , true )->andReturn ($ response );
3233 $ this ->assertEquals ($ response , $ middleware ->handle ($ request ));
3334
3435 $ request = Request::create ('/ ' , 'GET ' );
3536
36- $ app ->shouldReceive ('boot ' )->once ();
37- $ app ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => true ]));
37+ $ container ->shouldReceive ('boot ' )->once ();
38+ $ container ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => true ]));
3839 $ app ->shouldReceive ('handle ' )->once ()->with ($ request , HttpKernelInterface::MASTER_REQUEST , true )->andReturn ($ response );
3940
4041 $ this ->assertEquals ($ response , $ middleware ->handle ($ request ));
@@ -45,13 +46,14 @@ public function testLaravelMiddlewareIsHandledWhenNoApiRouteCollectionForRequest
4546 {
4647 $ response = new Response ;
4748 $ app = m::mock ('Symfony\Component\HttpKernel\HttpKernelInterface ' );
49+ $ container = m::mock ('Illuminate\Container\Container ' );
4850 $ router = m::mock ('Dingo\Api\Routing\Router ' );
49- $ middleware = new Authentication ($ app );
51+ $ middleware = new Authentication ($ app, $ container );
5052 $ request = Request::create ('/ ' , 'GET ' );
5153
52- $ app ->shouldReceive ('boot ' )->once ();
53- $ app ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
54- $ app ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
54+ $ container ->shouldReceive ('boot ' )->once ();
55+ $ container ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
56+ $ container ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
5557 $ app ->shouldReceive ('handle ' )->once ()->with ($ request , HttpKernelInterface::MASTER_REQUEST , true )->andReturn ($ response );
5658
5759 $ router ->shouldReceive ('getApiRouteCollectionFromRequest ' )->once ()->with ($ request )->andReturn (null );
@@ -64,14 +66,15 @@ public function testLaravelMiddlewareIsHandledWhenRouteNotFoundInApiRouteCollect
6466 {
6567 $ response = new Response ;
6668 $ app = m::mock ('Symfony\Component\HttpKernel\HttpKernelInterface ' );
69+ $ container = m::mock ('Illuminate\Container\Container ' );
6770 $ router = m::mock ('Dingo\Api\Routing\Router ' );
6871 $ collection = m::mock ('Dingo\Api\Routing\ApiRouteCollection ' );
69- $ middleware = new Authentication ($ app );
72+ $ middleware = new Authentication ($ app, $ container );
7073 $ request = Request::create ('/ ' , 'GET ' );
7174
72- $ app ->shouldReceive ('boot ' )->once ();
73- $ app ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
74- $ app ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
75+ $ container ->shouldReceive ('boot ' )->once ();
76+ $ container ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
77+ $ container ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
7578 $ app ->shouldReceive ('handle ' )->once ()->with ($ request , HttpKernelInterface::MASTER_REQUEST , true )->andReturn ($ response );
7679
7780 $ router ->shouldReceive ('getApiRouteCollectionFromRequest ' )->once ()->with ($ request )->andReturn ($ collection );
@@ -86,15 +89,16 @@ public function testLaravelMiddlewareIsHandledWhenRouteIsNotProtected()
8689 {
8790 $ response = new Response ;
8891 $ app = m::mock ('Symfony\Component\HttpKernel\HttpKernelInterface ' );
92+ $ container = m::mock ('Illuminate\Container\Container ' );
8993 $ router = m::mock ('Dingo\Api\Routing\Router ' );
9094 $ collection = m::mock ('Dingo\Api\Routing\ApiRouteCollection ' );
91- $ middleware = new Authentication ($ app );
95+ $ middleware = new Authentication ($ app, $ container );
9296 $ request = Request::create ('/ ' , 'GET ' );
9397 $ route = new Route ('GET ' , '/ ' , ['protected ' => false ]);
9498
95- $ app ->shouldReceive ('boot ' )->once ();
96- $ app ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
97- $ app ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
99+ $ container ->shouldReceive ('boot ' )->once ();
100+ $ container ->shouldReceive ('make ' )->once ()->with ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
101+ $ container ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
98102 $ app ->shouldReceive ('handle ' )->once ()->with ($ request , HttpKernelInterface::MASTER_REQUEST , true )->andReturn ($ response );
99103
100104 $ router ->shouldReceive ('getApiRouteCollectionFromRequest ' )->once ()->with ($ request )->andReturn ($ collection );
@@ -109,17 +113,18 @@ public function testAuthenticationFailsAndThrowExceptionIsHandled()
109113 {
110114 $ response = new Response ;
111115 $ app = m::mock ('Symfony\Component\HttpKernel\HttpKernelInterface ' );
116+ $ container = m::mock ('Illuminate\Container\Container ' );
112117 $ router = m::mock ('Dingo\Api\Routing\Router ' );
113118 $ collection = m::mock ('Dingo\Api\Routing\ApiRouteCollection ' );
114- $ middleware = new Authentication ($ app );
119+ $ middleware = new Authentication ($ app, $ container );
115120 $ request = Request::create ('/ ' , 'GET ' );
116121 $ route = new Route ('GET ' , '/ ' , ['protected ' ]);
117122 $ shield = m::mock ('Dingo\Api\Auth\Shield ' );
118123
119- $ app ->shouldReceive ('boot ' )->once ();
120- $ app ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
121- $ app ->shouldReceive ('make ' )->twice ()->with ('router ' )->andReturn ($ router );
122- $ app ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn ($ shield );
124+ $ container ->shouldReceive ('boot ' )->once ();
125+ $ container ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
126+ $ container ->shouldReceive ('make ' )->twice ()->with ('router ' )->andReturn ($ router );
127+ $ container ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn ($ shield );
123128
124129 $ router ->shouldReceive ('getApiRouteCollectionFromRequest ' )->once ()->with ($ request )->andReturn ($ collection );
125130
@@ -139,17 +144,18 @@ public function testAuthenticationPassesAndLaravelMiddlewareIsHandled()
139144 {
140145 $ response = new Response ;
141146 $ app = m::mock ('Symfony\Component\HttpKernel\HttpKernelInterface ' );
147+ $ container = m::mock ('Illuminate\Container\Container ' );
142148 $ router = m::mock ('Dingo\Api\Routing\Router ' );
143149 $ collection = m::mock ('Dingo\Api\Routing\ApiRouteCollection ' );
144- $ middleware = new Authentication ($ app );
150+ $ middleware = new Authentication ($ app, $ container );
145151 $ request = Request::create ('/ ' , 'GET ' );
146152 $ route = new Route ('GET ' , '/ ' , ['protected ' ]);
147153 $ shield = m::mock ('Dingo\Api\Auth\Shield ' );
148154
149- $ app ->shouldReceive ('boot ' )->once ();
150- $ app ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
151- $ app ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
152- $ app ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn ($ shield );
155+ $ container ->shouldReceive ('boot ' )->once ();
156+ $ container ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn (m::mock (['user ' => false ]));
157+ $ container ->shouldReceive ('make ' )->once ()->with ('router ' )->andReturn ($ router );
158+ $ container ->shouldReceive ('make ' )->once ()->once ('dingo.api.auth ' )->andReturn ($ shield );
153159 $ app ->shouldReceive ('handle ' )->once ()->with ($ request , HttpKernelInterface::MASTER_REQUEST , true )->andReturn ($ response );
154160
155161 $ router ->shouldReceive ('getApiRouteCollectionFromRequest ' )->once ()->with ($ request )->andReturn ($ collection );
0 commit comments