Add setting for yearly prevention mail
This commit is contained in:
parent
010ad80793
commit
a482e16739
|
@ -19,6 +19,7 @@ class SettingStoreAction
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'formmail' => 'array',
|
'formmail' => 'array',
|
||||||
|
'yearlymail' => 'array',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ class SettingStoreAction
|
||||||
{
|
{
|
||||||
$settings = app(PreventionSettings::class);
|
$settings = app(PreventionSettings::class);
|
||||||
$settings->formmail = EditorData::from($request->formmail);
|
$settings->formmail = EditorData::from($request->formmail);
|
||||||
|
$settings->yearlymail = EditorData::from($request->yearlymail);
|
||||||
$settings->save();
|
$settings->save();
|
||||||
|
|
||||||
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
Succeeded::message('Einstellungen gespeichert.')->dispatch();
|
||||||
|
|
|
@ -9,6 +9,7 @@ class PreventionSettings extends LocalSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
public EditorData $formmail;
|
public EditorData $formmail;
|
||||||
|
public EditorData $yearlymail;
|
||||||
|
|
||||||
public static function group(): string
|
public static function group(): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
|
||||||
|
return new class extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$this->migrator->add('prevention.yearlymail', ['time' => 1, 'blocks' => [], 'version' => '1.0']);
|
||||||
|
}
|
||||||
|
};
|
|
@ -5,36 +5,34 @@ namespace Tests\Feature\Prevention;
|
||||||
use App\Prevention\PreventionSettings;
|
use App\Prevention\PreventionSettings;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Tests\RequestFactories\EditorRequestFactory;
|
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
|
test()->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
|
||||||
{
|
});
|
||||||
$this->login()->loginNami();
|
|
||||||
|
|
||||||
$this->get('/setting/prevention')->assertComponent('setting/Prevention')->assertOk();
|
it('receives settings', function () {
|
||||||
}
|
test()->login()->loginNami();
|
||||||
|
|
||||||
public function testItReceivesSettings(): void
|
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
||||||
{
|
$yearlyMail = EditorRequestFactory::new()->text(50, 'lala dd')->toData();
|
||||||
$this->login()->loginNami();
|
app(PreventionSettings::class)->fill(['formmail' => $text, 'yearlymail' => $yearlyMail])->save();
|
||||||
|
|
||||||
$text = EditorRequestFactory::new()->text(50, 'lorem ipsum')->toData();
|
test()->get('/api/prevention')
|
||||||
app(PreventionSettings::class)->fill(['formmail' => $text])->save();
|
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum')
|
||||||
|
->assertJsonPath('data.yearlymail.blocks.0.data.text', 'lala dd');
|
||||||
|
});
|
||||||
|
|
||||||
$this->get('/api/prevention')
|
it('testItStoresSettings', function () {
|
||||||
->assertJsonPath('data.formmail.blocks.0.data.text', 'lorem ipsum');
|
test()->login()->loginNami();
|
||||||
}
|
|
||||||
|
|
||||||
public function testItStoresSettings(): void
|
$formmail = EditorRequestFactory::new()->text(50, 'new lorem')->create();
|
||||||
{
|
$yearlyMail = EditorRequestFactory::new()->text(50, 'lala dd')->create();
|
||||||
$this->login()->loginNami();
|
test()->post('/api/prevention', ['formmail' => $formmail, 'yearlymail' => $yearlyMail])->assertOk();
|
||||||
|
test()->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
||||||
$this->post('/api/prevention', ['formmail' => EditorRequestFactory::new()->text(50, 'new lorem')->create()])->assertOk();
|
test()->assertTrue(app(PreventionSettings::class)->yearlymail->hasAll(['lala dd']));
|
||||||
$this->assertTrue(app(PreventionSettings::class)->formmail->hasAll(['new lorem']));
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue