1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-06 18:04:03 +00:00
This commit is contained in:
lukinovec 2026-05-04 08:47:54 +02:00 committed by GitHub
commit 47abd579fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 2 deletions

View file

@ -300,7 +300,7 @@ test('using different default route modes works with global domain identificatio
$exception = match ($middleware) {
InitializeTenancyByDomain::class => TenantCouldNotBeIdentifiedOnDomainException::class,
InitializeTenancyBySubdomain::class => NotASubdomainException::class,
InitializeTenancyByDomainOrSubdomain::class => NotASubdomainException::class,
InitializeTenancyByDomainOrSubdomain::class => TenantCouldNotBeIdentifiedOnDomainException::class,
};
expect(fn () => $this->withoutExceptionHandling()->get('http://localhost/central-route'))->toThrow($exception);

View file

@ -7,6 +7,7 @@ use Stancl\Tenancy\Database\Concerns\HasDomains;
use Stancl\Tenancy\Exceptions\NotASubdomainException;
use Stancl\Tenancy\Middleware\InitializeTenancyBySubdomain;
use Stancl\Tenancy\Database\Models;
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
use function Stancl\Tenancy\Tests\pest;
beforeEach(function () {
@ -108,6 +109,14 @@ test('we cant use a subdomain that doesnt belong to our central domains', functi
->get('http://foo.localhost/foo/abc/xyz');
});
test('domain resolver correctly determines if string is a subdomain', function() {
config(['tenancy.identification.central_domains' => ['site.com', 'blog.site.com']]);
expect(DomainTenantResolver::isSubdomain('blog.site.com'))->toBeFalse();
expect(DomainTenantResolver::isSubdomain('tenant.site.com'))->toBeTrue();
expect(DomainTenantResolver::isSubdomain('tenantsite.com'))->toBeFalse();
});
class SubdomainTenant extends Models\Tenant
{
use HasDomains;