1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 23:14:05 +00:00

Test that the clone action can be used fluently without issues now (could serve as a regression test for the routesToClone change in previous commit)

This commit is contained in:
lukinovec 2025-06-12 09:09:19 +02:00
parent a196b72ac7
commit bdbfc2899c

View file

@ -272,3 +272,26 @@ test('tenant routes are ignored from cloning and clone middleware in groups caus
expect($allRouteNames->filter(fn($name) => str_contains($name, 'route-with-tenant-name-prefix'))->count())->toBe(1);
expect($allRouteNames->filter(fn($name) => str_contains($name, 'route-with-clone-in-mw-group'))->count())->toBe(1);
});
test('clone action can be used fluently', function() {
RouteFacade::get('/foo', fn () => true)->name('foo')->middleware('clone');
RouteFacade::get('/bar', fn () => true)->name('bar')->middleware('universal');
$cloneAction = app(CloneRoutesAsTenant::class);
// Clone foo route
$cloneAction->handle();
// Clone bar route
$cloneAction->cloneRoutesWithMiddleware(['universal'])->handle();
RouteFacade::get('/baz', fn () => true)->name('baz');
// Clone baz route
$cloneAction->cloneRoute('baz')->handle();
$routes = collect(RouteFacade::getRoutes()->get())->map->getName();
// Routes were cloned correctly
expect($routes)->toContain('tenant.foo', 'tenant.bar', 'tenant.baz');
});