diff --git a/src/Illuminate/Foundation/Http/Kernel.php b/src/Illuminate/Foundation/Http/Kernel.php index 368bb5fa0471..adb11d008175 100644 --- a/src/Illuminate/Foundation/Http/Kernel.php +++ b/src/Illuminate/Foundation/Http/Kernel.php @@ -383,6 +383,16 @@ protected function syncMiddlewareToRouter() } } + /** + * Get the priority-sorted list of middleware. + * + * @return array + */ + public function getMiddlewarePriority() + { + return $this->middlewarePriority; + } + /** * Get the bootstrap classes for the application. * diff --git a/tests/Foundation/Http/KernelTest.php b/tests/Foundation/Http/KernelTest.php index 1e25bb7051ad..5354af5a4d39 100644 --- a/tests/Foundation/Http/KernelTest.php +++ b/tests/Foundation/Http/KernelTest.php @@ -24,6 +24,22 @@ public function testGetRouteMiddleware() $this->assertEquals([], $kernel->getRouteMiddleware()); } + public function testGetMiddlewarePriority() + { + $kernel = new Kernel($this->getApplication(), $this->getRouter()); + + $this->assertEquals([ + \Illuminate\Cookie\Middleware\EncryptCookies::class, + \Illuminate\Session\Middleware\StartSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, + \Illuminate\Routing\Middleware\ThrottleRequests::class, + \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + \Illuminate\Auth\Middleware\Authorize::class, + ], $kernel->getMiddlewarePriority()); + } + /** * @return \Illuminate\Contracts\Foundation\Application */