middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]); $tenant = MaintenanceTenant::create(); $tenant->domains()->create([ 'domain' => 'acme.localhost', ]); pest()->get('http://acme.localhost/foo')->assertStatus(200); $tenant->putDownForMaintenance(); tenancy()->end(); // End tenancy before making a request pest()->get('http://acme.localhost/foo')->assertStatus(503); $tenant->bringUpFromMaintenance(); tenancy()->end(); // End tenancy before making a request pest()->get('http://acme.localhost/foo')->assertStatus(200); }); test('tenants can be put into maintenance mode using artisan commands', function() { Route::get('/foo', function () { return 'bar'; })->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]); $tenant = MaintenanceTenant::create(); $tenant->domains()->create([ 'domain' => 'acme.localhost', ]); pest()->get('http://acme.localhost/foo')->assertStatus(200); Artisan::call('tenants:down'); tenancy()->end(); // End tenancy before making a request pest()->get('http://acme.localhost/foo')->assertStatus(503); Artisan::call('tenants:up'); tenancy()->end(); // End tenancy before making a request pest()->get('http://acme.localhost/foo')->assertStatus(200); }); class MaintenanceTenant extends Tenant { use MaintenanceMode; }