From cde48a9b35ed8f923af7f9d9a197d96c65bf8238 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Mon, 29 Dec 2025 13:18:42 +0100 Subject: [PATCH] Add failling test for determining if string is subdomain --- tests/SubdomainTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/SubdomainTest.php b/tests/SubdomainTest.php index a7cc58ae..7d69bb20 100644 --- a/tests/SubdomainTest.php +++ b/tests/SubdomainTest.php @@ -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,13 @@ 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' => ['app.test']]); + + expect(DomainTenantResolver::isSubdomain('foo.app.test'))->toBeTrue(); + expect(DomainTenantResolver::isSubdomain('fooapp.test'))->toBeFalse(); +}); + class SubdomainTenant extends Models\Tenant { use HasDomains;