diff --git a/app/Prevention/Actions/SettingStoreAction.php b/app/Prevention/Actions/SettingStoreAction.php index cf72952c..18586524 100644 --- a/app/Prevention/Actions/SettingStoreAction.php +++ b/app/Prevention/Actions/SettingStoreAction.php @@ -19,6 +19,7 @@ class SettingStoreAction { return [ 'formmail' => 'array', + 'yearlymail' => 'array', ]; } @@ -26,6 +27,7 @@ class SettingStoreAction { $settings = app(PreventionSettings::class); $settings->formmail = EditorData::from($request->formmail); + $settings->yearlymail = EditorData::from($request->yearlymail); $settings->save(); Succeeded::message('Einstellungen gespeichert.')->dispatch(); diff --git a/app/Prevention/PreventionSettings.php b/app/Prevention/PreventionSettings.php index 01bfb1f2..d1832a0a 100644 --- a/app/Prevention/PreventionSettings.php +++ b/app/Prevention/PreventionSettings.php @@ -9,6 +9,7 @@ class PreventionSettings extends LocalSettings { public EditorData $formmail; + public EditorData $yearlymail; public static function group(): string { diff --git a/database/settings/2025_05_24_202013_create_prevention_yearly_mail_settings.php b/database/settings/2025_05_24_202013_create_prevention_yearly_mail_settings.php new file mode 100644 index 00000000..97b3b2f5 --- /dev/null +++ b/database/settings/2025_05_24_202013_create_prevention_yearly_mail_settings.php @@ -0,0 +1,11 @@ +migrator->add('prevention.yearlymail', ['time' => 1, 'blocks' => [], 'version' => '1.0']); + } +}; diff --git a/tests/Feature/Prevention/SettingTest.php b/tests/Feature/Prevention/SettingTest.php index b67fd4b4..1c61da8d 100644 --- a/tests/Feature/Prevention/SettingTest.php +++ b/tests/Feature/Prevention/SettingTest.php @@ -5,36 +5,34 @@ namespace Tests\Feature\Prevention; use App\Prevention\PreventionSettings; use Illuminate\Foundation\Testing\DatabaseTransactions; use Tests\RequestFactories\EditorRequestFactory; -use Tests\TestCase; -class SettingTest extends TestCase -{ +uses(DatabaseTransactions::class); - use DatabaseTransactions; +it('testItOpensSettingsPage', function () { + test()->withoutExceptionHandling(); + test()->login()->loginNami(); - public function testItOpensSettingsPage(): void - { - $this->login()->loginNami(); + test()->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk(); +}); - $this->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk(); - } +it('receives settings', function () { + test()->login()->loginNami(); - public function testItReceivesSettings(): void - { - $this->login()->loginNami(); + $text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData(); + $yearlyMail = EditorRequestFactory::new()->text(50, 'lala dd')->toData(); + app(PreventionSettings::class)->fill(['formmail' => $text, 'yearlymail' => $yearlyMail])->save(); - $text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData(); - app(PreventionSettings::class)->fill(['formmail' => $text])->save(); + test()->get('/api/prevention') + ->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum') + ->assertJsonPath('data.yearlymail.blocks.0.data.text', 'lala dd'); +}); - $this->get('/api/prevention') - ->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum'); - } +it('testItStoresSettings', function () { + test()->login()->loginNami(); - public function testItStoresSettings(): void - { - $this->login()->loginNami(); - - $this->post('/api/prevention', ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])->assertOk(); - $this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem'])); - } -} + $formmail = EditorRequestFactory::new()->text(50, 'new lorem')->create(); + $yearlyMail = EditorRequestFactory::new()->text(50, 'lala dd')->create(); + test()->post('/api/prevention', ['formmail' => $formmail, 'yearlymail' => $yearlyMail])->assertOk(); + test()->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem'])); + test()->assertTrue(app(PreventionSettings::class)->yearlymail->hasAll(['lala dd'])); +});