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:
parent
a196b72ac7
commit
bdbfc2899c
1 changed files with 23 additions and 0 deletions
|
|
@ -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');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue