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

simplify test: use concrete values instead of overly dynamic code

This commit is contained in:
Samuel Štancl 2024-12-20 03:55:10 +01:00
parent 4f94ccb5f7
commit 354ec1fb2a

View file

@ -85,19 +85,17 @@ test('root url bootstrapper can be used with url generator bootstrapper', functi
return true;
})->name('tenant.home')->middleware(InitializeTenancyByPath::class);
$rootUrlOverride = function (Tenant $tenant, string $originalRootUrl) {
return str($originalRootUrl)->beforeLast($tenant->getTenantKey())->toString() . '/' . $tenant->getTenantKey();
$rootUrlOverride = function (Tenant $tenant) {
return 'http://localhost/' . $tenant->getTenantKey();
};
$tenant = Tenant::create();
$tenantUrl = $rootUrlOverride($tenant, url('/'));
$tenant = Tenant::create(['id' => 'acme']);
RootUrlBootstrapper::$rootUrlOverride = $rootUrlOverride;
expect(route('home'))->toBe(url('/'));
expect(route('home'))->toBe('http://localhost');
tenancy()->initialize($tenant);
expect(route('home'))->toBe($tenantUrl);
expect(route('home'))->toBe('http://localhost/acme');
});