mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 01:34:02 +00:00
Merge branch 'master' of https://github.com/archtechx/tenancy into stein-j/3.x
This commit is contained in:
commit
c90ae845e9
89 changed files with 3782 additions and 3548 deletions
|
|
@ -2,86 +2,77 @@
|
|||
|
||||
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 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;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class MaintenanceModeTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function tenant_can_be_in_maintenance_mode()
|
||||
{
|
||||
Route::get('/foo', function () {
|
||||
return 'bar';
|
||||
})->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]);
|
||||
test('tenant can be in maintenance mode', function () {
|
||||
Route::get('/foo', function () {
|
||||
return 'bar';
|
||||
})->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]);
|
||||
|
||||
$tenant = MaintenanceTenant::create();
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'acme.localhost',
|
||||
]);
|
||||
$tenant = MaintenanceTenant::create();
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'acme.localhost',
|
||||
]);
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful();
|
||||
pest()->get('http://acme.localhost/foo')
|
||||
->assertSuccessful();
|
||||
|
||||
tenancy()->end(); // flush stored tenant instance
|
||||
tenancy()->end(); // Flush stored tenant instance
|
||||
|
||||
$tenant->putDownForMaintenance();
|
||||
$tenant->putDownForMaintenance();
|
||||
|
||||
$this->expectException(HttpException::class);
|
||||
$this->withoutExceptionHandling()
|
||||
->get('http://acme.localhost/foo');
|
||||
pest()->expectException(HttpException::class);
|
||||
pest()->withoutExceptionHandling()
|
||||
->get('http://acme.localhost/foo');
|
||||
|
||||
tenancy()->end();
|
||||
tenancy()->end();
|
||||
|
||||
$tenant->bringUpFromMaintenance();
|
||||
$tenant->bringUpFromMaintenance();
|
||||
|
||||
tenancy()->end();
|
||||
tenancy()->end();
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful()
|
||||
->assertSeeText('bar');
|
||||
}
|
||||
pest()->get('http://acme.localhost/foo')
|
||||
->assertSuccessful()
|
||||
->assertSeeText('bar');
|
||||
});
|
||||
|
||||
/** @test */
|
||||
public function tenant_can_be_in_maintenance_mode_from_command()
|
||||
{
|
||||
Route::get('/foo', function () {
|
||||
return 'bar';
|
||||
})->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]);
|
||||
test('tenant can be in maintenance mode from command', function() {
|
||||
Route::get('/foo', function () {
|
||||
return 'bar';
|
||||
})->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]);
|
||||
|
||||
$tenant = MaintenanceTenant::create();
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'acme.localhost',
|
||||
]);
|
||||
$tenant = MaintenanceTenant::create();
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'acme.localhost',
|
||||
]);
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful();
|
||||
pest()->get('http://acme.localhost/foo')
|
||||
->assertSuccessful();
|
||||
|
||||
tenancy()->end(); // flush stored tenant instance
|
||||
tenancy()->end(); // Flush stored tenant instance
|
||||
|
||||
Artisan::call('tenancy:down');
|
||||
Artisan::call('tenancy:down');
|
||||
|
||||
$this->expectException(HttpException::class);
|
||||
$this->withoutExceptionHandling()
|
||||
->get('http://acme.localhost/foo');
|
||||
pest()->expectException(HttpException::class);
|
||||
pest()->withoutExceptionHandling()
|
||||
->get('http://acme.localhost/foo');
|
||||
|
||||
tenancy()->end();
|
||||
tenancy()->end();
|
||||
|
||||
Artisan::call('tenancy:up');
|
||||
Artisan::call('tenancy:up');
|
||||
|
||||
tenancy()->end();
|
||||
tenancy()->end();
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful()
|
||||
->assertSeeText('bar');
|
||||
}
|
||||
}
|
||||
pest()->get('http://acme.localhost/foo')
|
||||
->assertSuccessful()
|
||||
->assertSeeText('bar');
|
||||
});
|
||||
|
||||
class MaintenanceTenant extends Tenant
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue