Skip to content

Commit bdbfc28

Browse files
committed
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)
1 parent a196b72 commit bdbfc28

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/CloneActionTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,26 @@
272272
expect($allRouteNames->filter(fn($name) => str_contains($name, 'route-with-tenant-name-prefix'))->count())->toBe(1);
273273
expect($allRouteNames->filter(fn($name) => str_contains($name, 'route-with-clone-in-mw-group'))->count())->toBe(1);
274274
});
275+
276+
test('clone action can be used fluently', function() {
277+
RouteFacade::get('/foo', fn () => true)->name('foo')->middleware('clone');
278+
RouteFacade::get('/bar', fn () => true)->name('bar')->middleware('universal');
279+
280+
$cloneAction = app(CloneRoutesAsTenant::class);
281+
282+
// Clone foo route
283+
$cloneAction->handle();
284+
285+
// Clone bar route
286+
$cloneAction->cloneRoutesWithMiddleware(['universal'])->handle();
287+
288+
RouteFacade::get('/baz', fn () => true)->name('baz');
289+
290+
// Clone baz route
291+
$cloneAction->cloneRoute('baz')->handle();
292+
293+
$routes = collect(RouteFacade::getRoutes()->get())->map->getName();
294+
295+
// Routes were cloned correctly
296+
expect($routes)->toContain('tenant.foo', 'tenant.bar', 'tenant.baz');
297+
});

0 commit comments

Comments
 (0)