1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-07 02:04:04 +00:00
tenancy/tests/Bootstrappers
lukinovec 984911946a
Change tenant storage listeners into jobs (#1446)
The `CreateTenantStorage` and `DeleteTenantStorage` listeners were used
alongside JobPipelines. When the `TenantCreated` JobPipeline had
`shouldBeQueued(true)` and the `Listeners\CreateTenantStorage` was
uncommented, the listener would throw an exception
(`Stancl\Tenancy\Database\Exceptions\TenantDatabaseDoesNotExistException
Database tenantX.sqlite does not exist.`) because at the time of
executing the listener, the tenant DB wasn't created yet.

The same issue could likely also occur in the `DeleteTenantStorage`
listener as it uses `tenancy()->run()` to resolve the tenant's storage
path which wouldn't work if the tenant's database (or other resources)
was already deleted, making initialization impossible.

This PR changes `DeleteTenantStorage` into a job and puts it (commented)
into the job pipeline, so that it can be queued with the rest of the
jobs. It also removes `CreateTenantStorage` because it should be
redundant with the FilesystemTenancyBootstrapper creating the same paths
automatically when storage path is suffixed.

The old classes are kept but deprecated for backwards compatibility.

We've also added some edge case hardening to `DeleteTenantStorage` to
make sure it never deletes the central storage path directory, which
previously could in theory occur due to a misconfiguration if a user
enabled this job/listener but disabled storage path suffixing.

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-04-22 16:45:54 +02:00
..
BootstrapperTest.php [4.x] Laravel 12 support (#1321) 2025-02-25 16:26:18 +01:00
BroadcastChannelPrefixBootstrapperTest.php [4.x] Laravel 12 support (#1321) 2025-02-25 16:26:18 +01:00
BroadcastingConfigBootstrapperTest.php Resolve test to-dos (#45) 2024-04-18 00:22:03 +02:00
CacheTagsBootstrapperTest.php [4.x] Support database cache store tenancy (#1290) (resolve #852) 2025-08-08 00:54:01 +02:00
CacheTenancyBootstrapperTest.php Resolve test to-dos (#45) 2024-04-18 00:22:03 +02:00
DatabaseSessionBootstrapperTest.php [4.x] Laravel 12 support (#1321) 2025-02-25 16:26:18 +01:00
DatabaseTenancyBootstrapper.php [4.x] Laravel 12 support (#1321) 2025-02-25 16:26:18 +01:00
FilesystemTenancyBootstrapperTest.php Change tenant storage listeners into jobs (#1446) 2026-04-22 16:45:54 +02:00
FortifyRouteBootstrapperTest.php [4.x] Resolve testing todos (#1361) 2025-08-03 23:21:03 +02:00
MailConfigBootstrapper.php rename mail bootstrapper test file 2024-09-27 21:03:39 +02:00
RootUrlBootstrapperTest.php [4.x] Improve RootUrl and UrlGenerator bootstrappers (#1294) 2025-01-16 10:30:06 +01:00
UrlGeneratorBootstrapperTest.php [4.x] Make URL::temporarySignedRoute() respect the bypass parameter (#1438) 2026-03-09 02:07:02 +01:00