File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -306,6 +306,16 @@ protected function parseControllerCallback()
306
306
return Str::parseCallback ($ this ->action ['uses ' ]);
307
307
}
308
308
309
+ /**
310
+ * Flush the cached container instance on the route.
311
+ *
312
+ * @return void
313
+ */
314
+ public function flushController ()
315
+ {
316
+ $ this ->controller = null ;
317
+ }
318
+
309
319
/**
310
320
* Determine if the route matches a given request.
311
321
*
Original file line number Diff line number Diff line change @@ -1866,6 +1866,25 @@ public function testJsonResponseIsReturned()
1866
1866
$ this ->assertInstanceOf (JsonResponse::class, $ response );
1867
1867
}
1868
1868
1869
+ public function testRouteFlush ()
1870
+ {
1871
+ $ container = new Container ;
1872
+ $ router = $ this ->getRouter ();
1873
+
1874
+ $ router ->get ('count ' , ActionCountStub::class);
1875
+ $ request = Request::create ('count ' , 'GET ' );
1876
+
1877
+ $ response = $ router ->dispatch ($ request );
1878
+ $ this ->assertSame (1 , (int ) $ response ->getContent ());
1879
+
1880
+ $ response = $ router ->dispatch ($ request );
1881
+ $ this ->assertSame (2 , (int ) $ response ->getContent ());
1882
+
1883
+ $ request ->route ()->flushController ();
1884
+ $ response = $ router ->dispatch ($ request );
1885
+ $ this ->assertSame (1 , (int ) $ response ->getContent ());
1886
+ }
1887
+
1869
1888
public function testRouteRedirect ()
1870
1889
{
1871
1890
$ container = new Container ;
@@ -2418,6 +2437,18 @@ public function __invoke()
2418
2437
}
2419
2438
}
2420
2439
2440
+ class ActionCountStub
2441
+ {
2442
+ protected $ count = 0 ;
2443
+
2444
+ public function __invoke ()
2445
+ {
2446
+ $ this ->count ++;
2447
+
2448
+ return $ this ->count ;
2449
+ }
2450
+ }
2451
+
2421
2452
interface ExampleMiddlewareContract
2422
2453
{
2423
2454
//
You can’t perform that action at this time.
0 commit comments