mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-06 18:04:03 +00:00
Add regression test for jobs recognizing pending tenants
Reverting the HasPending changes (in createPending(), create tenant without pending_since, and only after that, update the tenant to give it pending_since) makes the test fail.
This commit is contained in:
parent
e3673f5557
commit
e81e6ac651
1 changed files with 31 additions and 0 deletions
|
|
@ -336,3 +336,34 @@ test('pending tenant databases can be seeded using a job unless configured other
|
||||||
'seed with pending' => [true],
|
'seed with pending' => [true],
|
||||||
'seed without pending' => [false],
|
'seed without pending' => [false],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
test('jobs that run before tenants get fully created recognize pending tenants', function () {
|
||||||
|
config([
|
||||||
|
'tenancy.bootstrappers' => [DatabaseTenancyBootstrapper::class],
|
||||||
|
]);
|
||||||
|
|
||||||
|
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||||
|
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||||
|
Event::listen(TenantCreated::class, JobPipeline::make([
|
||||||
|
CreateDatabase::class,
|
||||||
|
PendingTenantJob::class,
|
||||||
|
])->send(function (TenantCreated $event) {
|
||||||
|
return $event->tenant;
|
||||||
|
})->toListener());
|
||||||
|
|
||||||
|
Tenant::createPending();
|
||||||
|
|
||||||
|
expect(app('tenant_is_pending'))->toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
class PendingTenantJob
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public Tenant $tenant,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
app()->instance('tenant_is_pending', $this->tenant->pending());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue