Move initialization of settings to trait
This commit is contained in:
parent
7c95e45178
commit
473241edca
2 changed files with 7 additions and 5 deletions
|
@ -4,5 +4,10 @@ namespace Tests\Support;
|
|||
|
||||
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\TestCase as BaseTestCase;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\Support\Settings;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
use LazilyRefreshDatabase;
|
||||
|
||||
protected Settings $settings;
|
||||
|
||||
private array $globallyDisabledMiddleware = [
|
||||
SecurityHeaders::class,
|
||||
];
|
||||
|
@ -25,8 +22,8 @@ abstract class TestCase extends BaseTestCase
|
|||
|
||||
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
||||
|
||||
if (in_array(InteractsWithSettings::class, class_uses_recursive($this))) {
|
||||
$this->settings = Settings::initialize();
|
||||
if (collect(class_uses_recursive($this))->contains(InteractsWithSettings::class)) {
|
||||
$this->setUpSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue