File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,7 @@ cp ../setup/alternative/database.php config/database.php
12
12
13
13
rm app/Providers/AppServiceProvider.php
14
14
cp ../setup/alternative/AppServiceProvider.php app/Providers/AppServiceProvider.php
15
+
16
+ if [ -f vendor/stancl/tenancy/src/Bootstrappers/PersistentQueueTenancyBootstrapper.php ]; then
17
+ sed -i ' s/QueueTenancyBootstrapper/PersistentQueueTenancyBootstrapper/g' config/tenancy.php
18
+ fi
Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ expect_worker_context() {
90
90
rm -f src/database.sqlite
91
91
rm -f src/database/tenantfoo.sqlite
92
92
rm -f src/database/tenantbar.sqlite
93
+ rm -f src/abc
94
+ rm -f src/sync_context
93
95
94
96
docker compose up -d redis # in case it's not running - the below setup code needs Redis to be running
95
97
231
233
echo " -------- SYNC PHASE --------"
232
234
echo
233
235
236
+ # The only thing we can check here is that dispatching a job doesn't revert the context to central
237
+ # when executed synchronously.
238
+
234
239
docker compose run --rm queue php artisan tinker -v --execute " tenancy()->initialize('foo'); App\Jobs\FooJob::dispatchSync(); file_put_contents('sync_context', tenant() ? ('tenant_' . tenant('id')) : 'central');"
235
240
without_queue_assertions assert_tenant_users foo 5
236
241
without_queue_assertions assert_tenant_users bar 1
@@ -256,10 +261,12 @@ assert_tenant_users bar 2
256
261
assert_central_users 2
257
262
echo " OK: User created in tenant bar"
258
263
259
- docker compose exec -T queue php artisan tinker --execute " \$ tenant = App\Models\Tenant::find('bar'); \$ tenant->update(['abc' => 'def']); \$ tenant->run(function () { dispatch(new App\Jobs\LogAbcJob); });"
264
+ EXPECTED_ABC=$( openssl rand -base64 12)
265
+
266
+ docker compose exec -T queue php artisan tinker --execute " \$ tenant = App\Models\Tenant::find('bar'); \$ tenant->update(['abc' => '${EXPECTED_ABC} ']); \$ tenant->run(function () { dispatch(new App\Jobs\LogAbcJob); });"
260
267
sleep 5
261
268
262
- if grep -q ' def ' src/abc; then
269
+ if grep -q $EXPECTED_ABC src/abc; then
263
270
echo " OK: Worker notices changes made to the current tenant outside the worker"
264
271
else
265
272
if [ " $FORCEREFRESH " -eq 1 ]; then
You can’t perform that action at this time.
0 commit comments