1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 23:14:03 +00:00
tenancy/tests/Features/RedirectTest.php
Samuel Štancl 8960a83047
[4.x] Laravel 12 support (#1321)
* Add Laravel 12 support, drop Laravel 11 support

* Fix RLS tree generation (specify schema name in generateTrees())

* ci fixes, use stable virtualcolumn version

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
2025-02-25 16:26:18 +01:00

37 lines
1 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Features\CrossDomainRedirect;
use Stancl\Tenancy\Tests\Etc\Tenant;
use function Stancl\Tenancy\Tests\pest;
test('tenant redirect macro replaces only the hostname', function () {
config([
'tenancy.features' => [CrossDomainRedirect::class],
]);
Route::get('/foobar', function () {
return 'Foo';
})->name('home');
Route::get('/redirect', function () {
return redirect()->route('home')->domain('abcd');
});
$tenant = Tenant::create();
tenancy()->initialize($tenant);
pest()->get('/redirect')
->assertRedirect('http://abcd/foobar');
});
test('tenant route helper generates correct url', function () {
Route::get('/abcdef/{a?}/{b?}', function () {
return 'Foo';
})->name('foo');
expect(tenant_route('foo.localhost', 'foo', ['a' => 'as', 'b' => 'df']))->toBe('http://foo.localhost/abcdef/as/df');
expect(tenant_route('foo.localhost', 'foo', []))->toBe('http://foo.localhost/abcdef');
});