From fad7e1199e63c001e8850204bd0dc5774c046196 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 2 Jul 2025 23:44:16 -0500 Subject: [PATCH] Create tests for app/Settings --- tests/Feature/app/SettingsTest.php | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/Feature/app/SettingsTest.php diff --git a/tests/Feature/app/SettingsTest.php b/tests/Feature/app/SettingsTest.php new file mode 100644 index 0000000..b3bd27f --- /dev/null +++ b/tests/Feature/app/SettingsTest.php @@ -0,0 +1,37 @@ +toBe('secret'); +}); + +it('can load settings from the database', function () { + Settings::$settings = null; + Settings::loadSettings(); + expect(Settings::$settings['registrationCode'])->toBe('secret'); +}); + +it('can return a setting value', function () { + expect(Settings::get('registrationCode'))->toBe('secret'); +}); + +it('can return a setting value, loading from DB if not in class', function () { + Settings::clearSettings(); + expect(Settings::get('registrationCode'))->toBe('secret'); +}); + +it('can modify a setting in the database', function () { + Settings::set('registrationCode', 'new'); + expect(SiteSetting::where('setting_key', 'registrationCode')->first()->setting_value)->toBe('new') + ->and(Settings::get('registrationCode'))->toBe('new'); +}); + +it('can clear settings from the class', function () { + Settings::clearSettings(); + expect(Settings::$settings)->toBeNull(); +});