File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 99use Illuminate \Support \Str ;
1010use Illuminate \Http \Request ;
1111use Illuminate \Container \Container ;
12+ use Illuminate \Support \Traits \Macroable ;
1213use Illuminate \Routing \Matching \UriValidator ;
1314use Illuminate \Routing \Matching \HostValidator ;
1415use Illuminate \Routing \Matching \MethodValidator ;
1819
1920class Route
2021{
21- use RouteDependencyResolverTrait;
22+ use Macroable, RouteDependencyResolverTrait;
2223
2324 /**
2425 * The URI pattern the route responds to.
Original file line number Diff line number Diff line change @@ -308,6 +308,25 @@ public function testMacro()
308308 $ this ->assertEquals ('OK ' , $ router ->dispatch (Request::create ('webhook ' , 'GET ' ))->getContent ());
309309 $ this ->assertEquals ('OK ' , $ router ->dispatch (Request::create ('webhook ' , 'POST ' ))->getContent ());
310310 }
311+
312+ public function testRouteMacro ()
313+ {
314+ $ router = $ this ->getRouter ();
315+
316+ Route::macro ('breadcrumb ' , function ($ breadcrumb ) {
317+ $ this ->action ['breadcrumb ' ] = $ breadcrumb ;
318+
319+ return $ this ;
320+ });
321+
322+ $ router ->get ('foo ' , function () {
323+ return 'bar ' ;
324+ })->breadcrumb ('fooBreadcrumb ' )->name ('foo ' );
325+
326+ $ router ->getRoutes ()->refreshNameLookups ();
327+
328+ $ this ->assertEquals ('fooBreadcrumb ' , $ router ->getRoutes ()->getByName ('foo ' )->getAction ()['breadcrumb ' ]);
329+ }
311330
312331 public function testClassesCanBeInjectedIntoRoutes ()
313332 {
You can’t perform that action at this time.
0 commit comments