1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 11:44:03 +00:00

Add failling test for determining if string is subdomain

This commit is contained in:
lukinovec 2025-12-29 13:18:42 +01:00
parent e3701f1cc1
commit cde48a9b35

View file

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