mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 16:14:03 +00:00
Add maintenance mode via commands test
This commit is contained in:
parent
e009ce9ad6
commit
7498b1bc17
2 changed files with 30 additions and 1 deletions
|
|
@ -7,9 +7,10 @@ namespace Stancl\Tenancy\Tests\Etc;
|
|||
use Stancl\Tenancy\Contracts\TenantWithDatabase;
|
||||
use Stancl\Tenancy\Database\Concerns\HasDatabase;
|
||||
use Stancl\Tenancy\Database\Concerns\HasDomains;
|
||||
use Stancl\Tenancy\Database\Concerns\MaintenanceMode;
|
||||
use Stancl\Tenancy\Database\Models;
|
||||
|
||||
class Tenant extends Models\Tenant implements TenantWithDatabase
|
||||
{
|
||||
use HasDatabase, HasDomains;
|
||||
use HasDatabase, HasDomains, MaintenanceMode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Stancl\Tenancy\Database\Concerns\MaintenanceMode;
|
||||
use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode;
|
||||
|
|
@ -48,7 +49,34 @@ class MaintenanceModeTest extends TestCase
|
|||
/** @test */
|
||||
public function tenant_can_be_in_maintenance_mode_from_command()
|
||||
{
|
||||
Route::get('/foo', function () {
|
||||
return 'bar';
|
||||
})->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]);
|
||||
|
||||
$tenant = MaintenanceTenant::create();
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'acme.localhost',
|
||||
]);
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful();
|
||||
|
||||
tenancy()->end(); // flush stored tenant instance
|
||||
|
||||
Artisan::call('tenancy:down');
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertStatus(503);
|
||||
|
||||
tenancy()->end();
|
||||
|
||||
Artisan::call('tenancy:up');
|
||||
|
||||
tenancy()->end();
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful()
|
||||
->assertSeeText('bar');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue