HEX
Server: nginx/1.28.3
System: Linux lightweb-s1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User: dawonefr-98 (1071)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/hasdeuac-119/has.deu.ac.kr/tests/TenantTestCase.php
<?php

namespace Tests;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Routing\UrlGenerator;

abstract class TenantTestCase extends TestCase
{
    use DatabaseMigrations;

    /**
     * Create tenant and initialize tenancy?
     *
     * @var bool
     */
    protected $tenancy = true;

    protected $shouldSeed = true;

    protected function setUp(): void
    {
        parent::setUp();

        if (! $this->shouldSeed) {
            config(['tenancy.seeder_parameters.--class' => EmptySeeder::class]);
        }

        if ($this->tenancy) {
            $tenant = $this->createTenant([], 'tenant');
            tenancy()->initialize($tenant);

            config(['app.url' => 'http://tenant.localhost']);

            /** @var UrlGenerator */
            $urlGenerator = url();
            $urlGenerator->forceRootUrl('http://tenant.localhost');

            $this->withServerVariables([
                'SERVER_NAME' => 'tenant.localhost',
                'HTTP_HOST' => 'tenant.localhost',
            ]);

            // Login as superuser
            auth()->loginUsingId(1);
        }
    }
}