File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
tests/TestCase/Routing/Route Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -486,6 +486,9 @@ public function parse($url, $method = '')
486
486
}
487
487
}
488
488
$ route ['_matchedRoute ' ] = $ this ->template ;
489
+ if (count ($ this ->middleware ) > 0 ) {
490
+ $ route ['_middleware ' ] = $ this ->middleware ;
491
+ }
489
492
490
493
return $ route ;
491
494
}
Original file line number Diff line number Diff line change @@ -1095,6 +1095,26 @@ public function testParseWithPassDefaults()
1095
1095
$ this ->assertEquals ($ expected , $ result );
1096
1096
}
1097
1097
1098
+ /**
1099
+ * Test that middleware is returned from parse()
1100
+ *
1101
+ * @return void
1102
+ */
1103
+ public function testParseWithMiddleware ()
1104
+ {
1105
+ $ route = new Route ('/:controller ' , ['action ' => 'display ' , 'home ' ]);
1106
+ $ route ->setMiddleware (['auth ' , 'cookie ' ]);
1107
+ $ result = $ route ->parse ('/posts ' , 'GET ' );
1108
+ $ expected = [
1109
+ 'controller ' => 'posts ' ,
1110
+ 'action ' => 'display ' ,
1111
+ 'pass ' => ['home ' ],
1112
+ '_matchedRoute ' => '/:controller ' ,
1113
+ '_middleware ' => ['auth ' , 'cookie ' ],
1114
+ ];
1115
+ $ this ->assertEquals ($ expected , $ result );
1116
+ }
1117
+
1098
1118
/**
1099
1119
* Test that http header conditions can cause route failures.
1100
1120
*
You can’t perform that action at this time.
0 commit comments