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

move only one test to without tenancy folder

This commit is contained in:
Abrar Ahmad 2022-11-30 13:42:45 +05:00
parent bbb8865b45
commit 068cee83ee
3 changed files with 37 additions and 31 deletions

View file

@ -283,7 +283,7 @@ return [
// Stancl\Tenancy\Features\TelescopeTags::class,
// Stancl\Tenancy\Features\UniversalRoutes::class,
// Stancl\Tenancy\Features\TenantConfig::class, // https://tenancyforlaravel.com/docs/v3/features/tenant-config
// Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancyforlaravel.com/docs/v3/features/cross-domain-redirect
Stancl\Tenancy\Features\CrossDomainRedirect::class, // https://tenancyforlaravel.com/docs/v3/features/cross-domain-redirect
],
/**

View file

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\TenancyServiceProvider;
use Stancl\Tenancy\Tests\Etc\Tenant;
test('tenant redirect macro replaces only the hostname', function () {
// `CrossDomainRedirect` feature already enabled in config
$this->app->register(new TenancyServiceProvider($this->app));
Route::get('/foobar', function () {
return 'Foo';
})->name('home');
Route::get('/redirect', function () {
return redirect()->route('home')->domain('abcd');
});
$tenant = Tenant::create(['id' => 'foo']);
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');
});

View file

@ -5,40 +5,10 @@ declare(strict_types=1);
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Features\CrossDomainRedirect;
use Stancl\Tenancy\TenancyServiceProvider;
use Stancl\Tenancy\Tests\Etc\Tenant;
use Stancl\Tenancy\Tests\WithoutTenancy\TestCase;
uses(TestCase::class);
test('tenant redirect macro replaces only the hostname', function () {
config()->set('tenancy.features', [CrossDomainRedirect::class]);
$this->app->register(new TenancyServiceProvider($this->app));
Route::get('/foobar', function () {
return 'Foo';
})->name('home');
Route::get('/redirect', function () {
return redirect()->route('home')->domain('abcd');
});
$tenant = Tenant::create(['id' => 'foo']); // todo automatic id generation is not working
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');
});
// Check that `domain()` can be called on a redirect before tenancy is used (regression test for #949)
test('redirect from central to tenant works', function (bool $enabled, bool $shouldThrow) {
if ($enabled) {