mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 11:54:03 +00:00
Refactor cached tenant resolvers with decorator pattern
This commit is contained in:
parent
8e3b74f9d1
commit
97e45ab9cc
15 changed files with 424 additions and 251 deletions
33
tests/Resolvers/RequestDataTenantResolverTest.php
Normal file
33
tests/Resolvers/RequestDataTenantResolverTest.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
|
||||
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Stancl\Tenancy\Tests\Repository\InMemoryTenantRepository;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->repository = new InMemoryTenantRepository();
|
||||
|
||||
$this->tenant = new Tenant();
|
||||
$this->tenant->id = 1;
|
||||
|
||||
$this->repository->store($this->tenant);
|
||||
});
|
||||
|
||||
it('resolves the tenant', function () {
|
||||
$resolver = new DomainTenantResolver(
|
||||
tenantRepository: $this->repository,
|
||||
);
|
||||
|
||||
$result = $resolver->resolve(id: 1);
|
||||
|
||||
expect($result)->toBe($this->tenant);
|
||||
});
|
||||
|
||||
it('throws when unable to find tenant', function () {
|
||||
$resolver = new DomainTenantResolver(
|
||||
tenantRepository: $this->repository,
|
||||
);
|
||||
|
||||
$resolver->resolve('foo');
|
||||
})->throws(TenantCouldNotBeIdentifiedOnDomainException::class);
|
||||
Loading…
Add table
Add a link
Reference in a new issue