1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 11:14:04 +00:00

deprecate JobBatchBootstrapper

This commit is contained in:
Samuel Štancl 2024-12-27 21:33:44 +01:00
parent 5777ff850f
commit eff41553d7
3 changed files with 15 additions and 67 deletions

View file

@ -1,46 +0,0 @@
<?php
use Illuminate\Bus\BatchRepository;
use Illuminate\Support\Facades\Event;
use Stancl\Tenancy\Bootstrappers\JobBatchBootstrapper;
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
use Stancl\Tenancy\Events\TenancyEnded;
use Stancl\Tenancy\Events\TenancyInitialized;
use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Listeners\RevertToCentralContext;
use Stancl\Tenancy\Tests\Etc\Tenant;
beforeEach(function () {
config([
'tenancy.bootstrappers' => [
DatabaseTenancyBootstrapper::class,
JobBatchBootstrapper::class,
],
]);
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
});
test('batch repository is set to tenant connection and reverted', function () {
withTenantDatabases();
$tenant = Tenant::create();
$tenant2 = Tenant::create();
expect(getBatchRepositoryConnectionName())->toBe('central');
tenancy()->initialize($tenant);
expect(getBatchRepositoryConnectionName())->toBe('tenant');
tenancy()->initialize($tenant2);
expect(getBatchRepositoryConnectionName())->toBe('tenant');
tenancy()->end();
expect(getBatchRepositoryConnectionName())->toBe('central');
});
function getBatchRepositoryConnectionName()
{
return app(BatchRepository::class)->getConnection()->getName();
}