diff --git a/src/Commands/Up.php b/src/Commands/Up.php index 6e68a02a..a3f690c2 100644 --- a/src/Commands/Up.php +++ b/src/Commands/Up.php @@ -13,7 +13,7 @@ class Up extends Command protected $signature = 'tenants:up'; - protected $description = 'Put tenants out of maintenance'; + protected $description = 'Put tenants out of maintenance mode.'; public function handle(): void { diff --git a/tests/MaintenanceModeTest.php b/tests/MaintenanceModeTest.php index 98fadbe0..6e28d1ab 100644 --- a/tests/MaintenanceModeTest.php +++ b/tests/MaintenanceModeTest.php @@ -4,13 +4,12 @@ declare(strict_types=1); use Illuminate\Support\Facades\Artisan; use Stancl\Tenancy\Database\Concerns\MaintenanceMode; -use Symfony\Component\HttpKernel\Exception\HttpException; use Illuminate\Support\Facades\Route; use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode; use Stancl\Tenancy\Middleware\InitializeTenancyByDomain; use Stancl\Tenancy\Tests\Etc\Tenant; -test('tenant can be in maintenance mode', function () { +test('tenants can be in maintenance mode', function () { Route::get('/foo', function () { return 'bar'; })->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]); @@ -20,27 +19,20 @@ test('tenant can be in maintenance mode', function () { 'domain' => 'acme.localhost', ]); - pest()->get('http://acme.localhost/foo') - ->assertSuccessful(); - - tenancy()->end(); // Flush stored tenant instance + 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); - tenancy()->end(); - $tenant->bringUpFromMaintenance(); - tenancy()->end(); - - pest()->get('http://acme.localhost/foo') - ->assertSuccessful() - ->assertSeeText('bar'); + tenancy()->end(); // End tenancy before making a request + pest()->get('http://acme.localhost/foo')->assertStatus(200); }); -test('tenant can be in maintenance mode from command', function() { +test('tenants can be put into maintenance mode using artisan commands', function() { Route::get('/foo', function () { return 'bar'; })->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]); @@ -50,24 +42,17 @@ test('tenant can be in maintenance mode from command', function() { 'domain' => 'acme.localhost', ]); - pest()->get('http://acme.localhost/foo') - ->assertSuccessful(); - - tenancy()->end(); // Flush stored tenant instance + 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); - tenancy()->end(); - Artisan::call('tenants:up'); - tenancy()->end(); - - pest()->get('http://acme.localhost/foo') - ->assertSuccessful() - ->assertSeeText('bar'); + tenancy()->end(); // End tenancy before making a request + pest()->get('http://acme.localhost/foo')->assertStatus(200); }); class MaintenanceTenant extends Tenant