mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Move initialization of settings to trait
This commit is contained in:
parent
7c95e45178
commit
473241edca
|
@ -4,5 +4,10 @@ namespace Tests\Support;
|
||||||
|
|
||||||
trait InteractsWithSettings
|
trait InteractsWithSettings
|
||||||
{
|
{
|
||||||
|
protected Settings $settings;
|
||||||
|
|
||||||
|
public function setUpSettings()
|
||||||
|
{
|
||||||
|
$this->settings = Settings::initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,12 @@ use App\Http\Middleware\SecurityHeaders;
|
||||||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||||
use Tests\Support\InteractsWithSettings;
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\Support\Settings;
|
|
||||||
|
|
||||||
abstract class TestCase extends BaseTestCase
|
abstract class TestCase extends BaseTestCase
|
||||||
{
|
{
|
||||||
use CreatesApplication;
|
use CreatesApplication;
|
||||||
use LazilyRefreshDatabase;
|
use LazilyRefreshDatabase;
|
||||||
|
|
||||||
protected Settings $settings;
|
|
||||||
|
|
||||||
private array $globallyDisabledMiddleware = [
|
private array $globallyDisabledMiddleware = [
|
||||||
SecurityHeaders::class,
|
SecurityHeaders::class,
|
||||||
];
|
];
|
||||||
|
@ -25,8 +22,8 @@ abstract class TestCase extends BaseTestCase
|
||||||
|
|
||||||
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
||||||
|
|
||||||
if (in_array(InteractsWithSettings::class, class_uses_recursive($this))) {
|
if (collect(class_uses_recursive($this))->contains(InteractsWithSettings::class)) {
|
||||||
$this->settings = Settings::initialize();
|
$this->setUpSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue