Compare commits

..

No commits in common. "3b63a73161b2585af2650c56c1caf7d75bde3745" and "96cf0b7dd54f60e71df4031308ae33200bb0e1ac" have entirely different histories.

3 changed files with 12 additions and 27 deletions

View File

@ -27,7 +27,7 @@ class PreventionRememberAction
return; return;
} }
$body = app(PreventionSettings::class)->refresh()->formmail $body = app(PreventionSettings::class)->formmail
->placeholder('formname', $participant->form->name) ->placeholder('formname', $participant->form->name)
->append($participant->form->prevention_text); ->append($participant->form->prevention_text);

View File

@ -42,14 +42,15 @@ class EditorData extends Data implements Editorable
public function append(Editorable $editorable): self public function append(Editorable $editorable): self
{ {
$this->blocks = array_merge($this->blocks, $editorable->toEditorData()->blocks); return self::from([
...$this->toArray(),
return $this; 'blocks' => array_merge($this->blocks, $editorable->toEditorData()->blocks),
]);
} }
public function replaceWithList(string $blockContent, array $replacements): self public function replaceWithList(string $blockContent, array $replacements): self
{ {
$this->blocks = collect($this->blocks)->map(function ($block) use ($blockContent, $replacements) { $blocks = collect($this->blocks)->map(function ($block) use ($blockContent, $replacements) {
if (data_get($block, 'type') !== 'paragraph') { if (data_get($block, 'type') !== 'paragraph') {
return $block; return $block;
} }
@ -71,8 +72,10 @@ class EditorData extends Data implements Editorable
return $block; return $block;
})->toArray(); })->toArray();
return self::from([
return $this; ...$this->toArray(),
'blocks' => $blocks,
]);
} }
public function toEditorData(): EditorData public function toEditorData(): EditorData

View File

@ -186,7 +186,7 @@ class PreventionTest extends TestCase
public function testItRendersSetttingMail(): void public function testItRendersSetttingMail(): void
{ {
Mail::fake(); Mail::fake();
app(PreventionSettings::class)->fill([ app(PreventionSettings::class)->fake([
'formmail' => EditorRequestFactory::new()->paragraphs(["lorem lala {formname} g", "{wanted}", "bbb"])->toData() 'formmail' => EditorRequestFactory::new()->paragraphs(["lorem lala {formname} g", "{wanted}", "bbb"])->toData()
])->save(); ])->save();
$form = $this->createForm(); $form = $this->createForm();
@ -203,7 +203,7 @@ class PreventionTest extends TestCase
public function testItAppendsTextOfForm(): void public function testItAppendsTextOfForm(): void
{ {
Mail::fake(); Mail::fake();
app(PreventionSettings::class)->fill([ app(PreventionSettings::class)->fake([
'formmail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData() 'formmail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData()
])->save(); ])->save();
$form = $this->createForm(); $form = $this->createForm();
@ -217,24 +217,6 @@ class PreventionTest extends TestCase
])); ]));
} }
public function testItDoesntAppendTextTwice(): void
{
Mail::fake();
app(PreventionSettings::class)->fill(['frommail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData()])->save();
tap($this->createForm(), function ($f) {
$f->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['oberhausen'])->toData()]);
$this->createParticipant($f);
});
tap($this->createForm(), function ($f) {
$f->update(['prevention_text' => EditorRequestFactory::new()->paragraphs(['siegburg'])->toData()]);
$this->createParticipant($f);
});
PreventionRememberAction::run();
Mail::assertSent(PreventionRememberMail::class, fn ($mail) => $mail->bodyText->hasAll(['oberhausen']) && !$mail->bodyText->hasAll(['siegburg']));
}
public function testItDisplaysBodyTextInMail(): void public function testItDisplaysBodyTextInMail(): void
{ {
$form = $this->createForm(); $form = $this->createForm();