From b86f70ba4f612d6159f876fad8808890434f8e04 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Thu, 20 Oct 2016 22:12:51 +0200 Subject: [PATCH] Present unqiue sorted middleware --- src/Illuminate/Routing/SortedMiddleware.php | 2 +- tests/Routing/RoutingSortedMiddlewareTest.php | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Routing/SortedMiddleware.php b/src/Illuminate/Routing/SortedMiddleware.php index 1e3cf797a2c4..ec881c3d77ba 100644 --- a/src/Illuminate/Routing/SortedMiddleware.php +++ b/src/Illuminate/Routing/SortedMiddleware.php @@ -65,7 +65,7 @@ protected function sortMiddleware($priorityMap, $middlewares) } } - return $middlewares; + return array_values(array_unique($middlewares, SORT_REGULAR)); } /** diff --git a/tests/Routing/RoutingSortedMiddlewareTest.php b/tests/Routing/RoutingSortedMiddlewareTest.php index 4f3d74655899..baa84c8176f0 100644 --- a/tests/Routing/RoutingSortedMiddlewareTest.php +++ b/tests/Routing/RoutingSortedMiddlewareTest.php @@ -18,8 +18,7 @@ public function testMiddlewareCanBeSortedByPriority() 'Something', 'Something', 'Second', - 'Something', - 'Something', + 'Otherthing', 'First:api', 'Third:foo', 'First:foo,bar', @@ -28,16 +27,11 @@ public function testMiddlewareCanBeSortedByPriority() ]; $expected = [ - 'Something', - 'Something', - 'Something', 'Something', 'First:api', 'First:foo,bar', 'Second', - 'Something', - 'Something', - 'Second', + 'Otherthing', 'Third:foo', 'Third', ];