mirror of
https://github.com/snipe/snipe-it.git
synced 2026-08-18 11:15:42 +00:00
24 lines
707 B
PHP
24 lines
707 B
PHP
<?php
|
|
|
|
namespace Tests\Support;
|
|
|
|
use App\Models\Setting;
|
|
use App\Models\Statuslabel;
|
|
|
|
trait InitializesSettings
|
|
{
|
|
protected Settings $settings;
|
|
|
|
public function initializeSettings()
|
|
{
|
|
$this->settings = Settings::initialize();
|
|
|
|
$this->beforeApplicationDestroyed(fn () => Setting::$_cache = null);
|
|
// Same idea as Setting::$_cache — a per-request memo lives across
|
|
// tests if we don't explicitly reset it. Without this, the second
|
|
// test in a file would see status_label IDs from the *previous*
|
|
// test's transactional rows (which have since rolled back).
|
|
$this->beforeApplicationDestroyed(fn () => Statuslabel::clearIdCache());
|
|
}
|
|
}
|