mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 05:14:05 +00:00
Instead of assigning $innerMiddleware during group MW unpacking, merge it (#1371)
This commit is contained in:
parent
1e926a1dde
commit
d1f12f594d
2 changed files with 13 additions and 1 deletions
|
|
@ -110,7 +110,7 @@ trait DealsWithRouteContexts
|
|||
|
||||
foreach ($middleware as $inner) {
|
||||
if (! $inner instanceof Closure && isset($middlewareGroups[$inner])) {
|
||||
$innerMiddleware = Arr::wrap($middlewareGroups[$inner]);
|
||||
$innerMiddleware = array_merge($innerMiddleware, Arr::wrap($middlewareGroups[$inner]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,18 @@ test('tenancy detects presence of route middleware correctly', function (string
|
|||
InitializeTenancyByDomainOrSubdomain::class,
|
||||
]);
|
||||
|
||||
test('getRouteMiddleware properly unpacks all mw groups on a route', function() {
|
||||
$route = Route::get('/foo', fn () => true)->middleware(['foo', 'bar']);
|
||||
|
||||
Route::middlewareGroup('foo', [PreventAccessFromUnwantedDomains::class]);
|
||||
Route::middlewareGroup('bar', [InitializeTenancyByDomain::class]);
|
||||
|
||||
expect(tenancy()->getRouteMiddleware($route))->toContain(
|
||||
PreventAccessFromUnwantedDomains::class,
|
||||
InitializeTenancyByDomain::class
|
||||
);
|
||||
});
|
||||
|
||||
test('domain identification middleware is configurable', function() {
|
||||
$route = Route::get('/welcome-route', fn () => 'welcome')->middleware([InitializeTenancyByDomain::class]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue