mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 00:24:02 +00:00
Convert test cases
This commit is contained in:
parent
405b91085e
commit
a8dcd0dfc9
27 changed files with 3059 additions and 3658 deletions
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
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;
|
||||
|
|
@ -13,34 +11,26 @@ 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]);
|
||||
uses(Stancl\Tenancy\Tests\TestCase::class);
|
||||
|
||||
$tenant = MaintenanceTenant::create();
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'acme.localhost',
|
||||
]);
|
||||
test('tenant can be in maintenance mode', function () {
|
||||
Route::get('/foo', function () {
|
||||
return 'bar';
|
||||
})->middleware([InitializeTenancyByDomain::class, CheckTenantForMaintenanceMode::class]);
|
||||
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful();
|
||||
$tenant = MaintenanceTenant::create();
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'acme.localhost',
|
||||
]);
|
||||
|
||||
tenancy()->end(); // flush stored tenant instance
|
||||
$this->get('http://acme.localhost/foo')
|
||||
->assertSuccessful();
|
||||
|
||||
$tenant->putDownForMaintenance();
|
||||
tenancy()->end(); // flush stored tenant instance
|
||||
|
||||
$this->expectException(HttpException::class);
|
||||
$this->withoutExceptionHandling()
|
||||
->get('http://acme.localhost/foo');
|
||||
}
|
||||
}
|
||||
$tenant->putDownForMaintenance();
|
||||
|
||||
class MaintenanceTenant extends Tenant
|
||||
{
|
||||
use MaintenanceMode;
|
||||
}
|
||||
$this->expectException(HttpException::class);
|
||||
$this->withoutExceptionHandling()
|
||||
->get('http://acme.localhost/foo');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue