mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 17:14:03 +00:00
improve test logic
This commit is contained in:
parent
99b86bf07a
commit
9358819c24
2 changed files with 11 additions and 26 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue