41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use App\Models\Tenant;
|
|
use App\Tenancy\Tenancy;
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
/**
|
|
* Default tenant used by tests. Created at setUp; flushed after.
|
|
* Auto-attached as the X-Tenant-Code header on every JSON request
|
|
* so existing tests don't need per-test boilerplate.
|
|
*/
|
|
protected ?Tenant $defaultTenant = null;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
\Illuminate\Support\Facades\Queue::fake([\App\Jobs\SyncLguBarangaysJob::class]);
|
|
$this->defaultTenant = Tenant::firstOrCreate(
|
|
['code' => 'TEST-LGU'],
|
|
[
|
|
'name' => 'Test LGU',
|
|
'short_name' => 'Test',
|
|
'status' => Tenant::STATUS_ACTIVE,
|
|
],
|
|
);
|
|
Tenancy::setCurrent($this->defaultTenant);
|
|
|
|
$this->withHeaders(['X-Tenant-Code' => $this->defaultTenant->code]);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
Tenancy::clear();
|
|
parent::tearDown();
|
|
}
|
|
}
|