mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:14:03 +00:00
* Test on Laravel 9 * Don't extend final Kernel class * Make FilesystemTenancyBootstrapper compatible with Flysystem v3 Co-authored-by: George <jiri.zizka@funfirst.cz> * Update tenant maintenance mode te be in line with Laravel * Exclude PHP 7.4 <> L9 combination from testing * add root_override-related assertions * getPrefix -> getPathPrefix * handle / inconsistency in s3 prefix * Refactor Storage facade changes Co-authored-by: George <jiri.zizka@funfirst.cz> Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Stancl\Tenancy\Tests;
|
|
|
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Stancl\Tenancy\Database\Concerns\MaintenanceMode;
|
|
use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode;
|
|
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
|
|
use Stancl\Tenancy\Tests\Etc\Tenant;
|
|
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
|
|
|
class MaintenanceModeTest extends TestCase
|
|
{
|
|
/** @test */
|
|
public function tenant_can_be_in_maintenance_mode()
|
|
{
|
|
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
|
|
|
|
$tenant->putDownForMaintenance();
|
|
|
|
$this->expectException(HttpException::class);
|
|
$this->withoutExceptionHandling()
|
|
->get('http://acme.localhost/foo');
|
|
}
|
|
}
|
|
|
|
class MaintenanceTenant extends Tenant
|
|
{
|
|
use MaintenanceMode;
|
|
}
|