From 6e37f945ac081493d1db188bb7d773e86414bc12 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 2 Jun 2025 17:13:37 -0700 Subject: [PATCH] Add test helpers --- tests/Feature/Settings/AlertsSettingTest.php | 2 +- tests/Support/Settings.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Settings/AlertsSettingTest.php b/tests/Feature/Settings/AlertsSettingTest.php index 6dae959648..42974d6640 100644 --- a/tests/Feature/Settings/AlertsSettingTest.php +++ b/tests/Feature/Settings/AlertsSettingTest.php @@ -47,7 +47,7 @@ class AlertsSettingTest extends TestCase public function test_can_update_admin_cc_always_to_false() { - $this->settings->enableAdminCCAlways(); + $this->settings->enableAdminCC()->enableAdminCCAlways(); $this->actingAs(User::factory()->superuser()->create()) ->post(route('settings.alerts.save', ['admin_cc_always' => '0'])); diff --git a/tests/Support/Settings.php b/tests/Support/Settings.php index bcbd83d8b6..d33970e683 100644 --- a/tests/Support/Settings.php +++ b/tests/Support/Settings.php @@ -4,6 +4,7 @@ namespace Tests\Support; use App\Models\Setting; use Illuminate\Support\Facades\Crypt; +use RuntimeException; class Settings { @@ -60,6 +61,24 @@ class Settings ]); } + public function enableAdminCCAlways(): Settings + { + if (is_null($this->setting->admin_cc_email) || $this->setting->admin_cc_email == 0) { + throw new RuntimeException('admin_cc_email requires admin_cc_email to be set.'); + } + + return $this->update([ + 'admin_cc_always' => 1, + ]); + } + + public function disableAdminCCAlways(): Settings + { + return $this->update([ + 'admin_cc_always' => 0, + ]); + } + public function enableMultipleFullCompanySupport(): Settings { return $this->update(['full_multiple_companies_support' => 1]);