@@ -1772,14 +1772,17 @@ public function testRouteFlushController()
1772
1772
$ request = Request::create ('count ' , 'GET ' );
1773
1773
1774
1774
$ response = $ router ->dispatch ($ request );
1775
- $ this ->assertSame (1 , (int ) $ response ->getContent ());
1775
+ $ this ->assertSame (1 , $ response ->original ['invokedCount ' ]);
1776
+ $ this ->assertSame (1 , $ response ->original ['middlewareInvokedCount ' ]);
1776
1777
1777
1778
$ response = $ router ->dispatch ($ request );
1778
- $ this ->assertSame (2 , (int ) $ response ->getContent ());
1779
+ $ this ->assertSame (2 , $ response ->original ['invokedCount ' ]);
1780
+ $ this ->assertSame (2 , $ response ->original ['middlewareInvokedCount ' ]);
1779
1781
1780
1782
$ request ->route ()->flushController ();
1781
1783
$ response = $ router ->dispatch ($ request );
1782
- $ this ->assertSame (1 , (int ) $ response ->getContent ());
1784
+ $ this ->assertSame (1 , $ response ->original ['invokedCount ' ]);
1785
+ $ this ->assertSame (1 , $ response ->original ['middlewareInvokedCount ' ]);
1783
1786
}
1784
1787
1785
1788
public function testJsonResponseIsReturned ()
@@ -2323,15 +2326,29 @@ public function __invoke()
2323
2326
}
2324
2327
}
2325
2328
2326
- class ActionCountStub
2329
+ class ActionCountStub extends Controller
2327
2330
{
2328
- protected $ count = 0 ;
2331
+ protected $ middlewareInvokedCount = 0 ;
2332
+
2333
+ protected $ invokedCount = 0 ;
2334
+
2335
+ public function __construct ()
2336
+ {
2337
+ $ this ->middleware (function ($ request , $ next ) {
2338
+ $ this ->middlewareInvokedCount ++;
2339
+
2340
+ return $ next ($ request );
2341
+ });
2342
+ }
2329
2343
2330
2344
public function __invoke ()
2331
2345
{
2332
- $ this ->count ++;
2346
+ $ this ->invokedCount ++;
2333
2347
2334
- return $ this ->count ;
2348
+ return [
2349
+ 'invokedCount ' => $ this ->invokedCount ,
2350
+ 'middlewareInvokedCount ' => $ this ->middlewareInvokedCount ,
2351
+ ];
2335
2352
}
2336
2353
}
2337
2354
0 commit comments