mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 04:34:03 +00:00
Add test for handling 'clone' in MW groups
This commit is contained in:
parent
875d6409cb
commit
4c32599c57
1 changed files with 25 additions and 0 deletions
|
|
@ -214,3 +214,28 @@ test('clone action trims trailing slashes from prefixes given to nested route gr
|
||||||
->not()->toContain("prefix//")
|
->not()->toContain("prefix//")
|
||||||
->toBe("http://localhost/prefix/{$tenant->getTenantKey()}/home");
|
->toBe("http://localhost/prefix/{$tenant->getTenantKey()}/home");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('clone middleware within middleware groups is properly handled during cloning', function () {
|
||||||
|
// Define a middleware group that contains the 'clone' flag along with the 'auth' MW
|
||||||
|
RouteFacade::middlewareGroup('mw-group-with-clone', ['auth', 'clone']);
|
||||||
|
|
||||||
|
RouteFacade::get('/foo', fn () => true)
|
||||||
|
->middleware('mw-group-with-clone')
|
||||||
|
->name('foo');
|
||||||
|
|
||||||
|
app(CloneRoutesAsTenant::class)->handle();
|
||||||
|
|
||||||
|
// Route 'foo' should be cloned as 'tenant.foo'
|
||||||
|
$clonedRoute = RouteFacade::getRoutes()->getByName('tenant.foo');
|
||||||
|
|
||||||
|
expect($clonedRoute)->not()->toBeNull();
|
||||||
|
|
||||||
|
$clonedRouteMiddleware = tenancy()->getRouteMiddleware($clonedRoute);
|
||||||
|
|
||||||
|
// The cloned route should still have other middleware from the group,
|
||||||
|
// but it should NOT have the original middleware group name.
|
||||||
|
// Instead, the middleware should be extracted from the group and applied directly.
|
||||||
|
expect($clonedRouteMiddleware)
|
||||||
|
->toContain('auth')
|
||||||
|
->not()->toContain('test-group', 'clone');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue