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

throw correct exception when $originalOnFail() is null

This commit is contained in:
Abrar Ahmad 2022-07-22 18:35:37 +05:00
parent 8fb3eb0abd
commit 17fecf29a1
2 changed files with 17 additions and 1 deletions

View file

@ -30,7 +30,11 @@ class UniversalRoutes implements Feature
return $next($request); return $next($request);
} }
if ($originalOnFail) {
return $originalOnFail($exception, $request, $next); return $originalOnFail($exception, $request, $next);
}
throw $exception;
}; };
} }
} }

View file

@ -10,6 +10,7 @@ use Stancl\Tenancy\Database\Models;
use Stancl\Tenancy\Database\Models\Domain; use Stancl\Tenancy\Database\Models\Domain;
use Stancl\Tenancy\Exceptions\DomainOccupiedByOtherTenantException; use Stancl\Tenancy\Exceptions\DomainOccupiedByOtherTenantException;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException; use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
use Stancl\Tenancy\Features\UniversalRoutes;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain; use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Resolvers\DomainTenantResolver; use Stancl\Tenancy\Resolvers\DomainTenantResolver;
@ -105,6 +106,17 @@ class DomainTest extends TestCase
->assertSee('foo'); ->assertSee('foo');
} }
/** @test */
public function not_defining_onfail_customized_logic_throw_correct_exception_when_universal_route_feature_enabled()
{
// Enable UniversalRoute feature
Route::middlewareGroup('universal', []);
config(['tenancy.features' => [UniversalRoutes::class]]);
$this->expectException(TenantCouldNotBeIdentifiedOnDomainException::class);
$this->withoutExceptionHandling()->get('http://foo.localhost/foo/abc/xyz');
}
/** @test */ /** @test */
public function domains_are_always_lowercase() public function domains_are_always_lowercase()
{ {