3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-18 11:15:42 +00:00
Files
snipe-it/tests/Support/InitializesSettings.php
2026-06-30 14:52:55 +01:00

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());
}
}