1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 09:04:03 +00:00

tests added

This commit is contained in:
Chinmay Purav 2024-09-12 23:41:11 +05:30
parent 14fe3c71c1
commit 276d44ac04

View file

@ -4,6 +4,9 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
use Illuminate\Support\Facades\Event;
use Stancl\Tenancy\Events\TenantGoingInMaintenanceMode;
use Stancl\Tenancy\Events\TenantWentInMaintenanceMode;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
use Illuminate\Support\Facades\Route;
@ -18,6 +21,8 @@ class MaintenanceModeTest extends TestCase
/** @test */
public function tenant_can_be_in_maintenance_mode()
{
Event::fake([TenantGoingInMaintenanceMode::class, TenantWentInMaintenanceMode::class]);
Route::get('/foo', function () {
return 'bar';
})->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]);
@ -32,8 +37,14 @@ class MaintenanceModeTest extends TestCase
tenancy()->end(); // flush stored tenant instance
Event::assertNotDispatched(TenantGoingInMaintenanceMode::class);
Event::assertNotDispatched(TenantWentInMaintenanceMode::class);
$tenant->putDownForMaintenance();
Event::assertDispatched(TenantGoingInMaintenanceMode::class);
Event::assertDispatched(TenantWentInMaintenanceMode::class);
$this->expectException(HttpException::class);
$this->withoutExceptionHandling()
->get('http://acme.localhost/foo');