mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 16:24:04 +00:00
* Only retrieve domains if the relationship and the domains table exist (DomianTenantResolver) * Resolve todo, add other todos * Use constructor promotion in DeleteDomains * Fix imports + domain deletion test * Confirm that turning on resolver caching doesn't break the tests * Fix Tenant model imports * Fix code style (php-cs-fixer) * remove runtime schema check * temp: enable resolver cache * make 'autoincrement ids are supported' pass * disable resolver cache --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com> Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com> Co-authored-by: Samuel Štancl <samuel@archte.ch>
27 lines
613 B
PHP
27 lines
613 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
|
use Stancl\Tenancy\Jobs\DeleteDomains;
|
|
|
|
beforeEach(function () {
|
|
config(['tenancy.models.tenant' => Tenant::class]);
|
|
});
|
|
|
|
test('job deletes domains successfully', function () {
|
|
$tenant = Tenant::create();
|
|
|
|
$tenant->domains()->create([
|
|
'domain' => 'foo.localhost',
|
|
]);
|
|
$tenant->domains()->create([
|
|
'domain' => 'bar.localhost',
|
|
]);
|
|
|
|
expect($tenant->domains()->count())->toBe(2);
|
|
|
|
(new DeleteDomains($tenant->refresh()))->handle();
|
|
|
|
expect($tenant->refresh()->domains()->count())->toBe(0);
|
|
});
|