1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 11:14:04 +00:00

Cloning: improve type annotations, add cloneRoutes() for convenience

This commit is contained in:
Samuel Štancl 2025-11-09 01:27:29 +01:00
parent 197513dd84
commit 6ef4b91744
No known key found for this signature in database
GPG key ID: BA146259A1E16C57
2 changed files with 60 additions and 6 deletions

View file

@ -464,3 +464,14 @@ test('addTenantMiddleware can be used to specify the tenant middleware for the c
expect($cloned->getDomain())->toBe('foo.localhost');
expect(tenancy()->getRouteMiddleware($cloned))->toBe([InitializeTenancyByDomain::class]);
});
test('cloneRoutes can be used to clone multiple routes', function () {
RouteFacade::get('/foo', fn () => true)->name('foo');
$bar = RouteFacade::get('/bar', fn () => true)->name('bar');
RouteFacade::get('/baz', fn () => true)->name('baz');
CloneRoutesAsTenant::make()->cloneRoutes(['foo', $bar])->handle();
expect(collect(RouteFacade::getRoutes()->get())->map->getName())->toContain('tenant.foo');
expect(collect(RouteFacade::getRoutes()->get())->map->getName())->toContain('tenant.bar');
expect(collect(RouteFacade::getRoutes()->get())->map->getName())->not()->toContain('tenant.baz');
});