Compare commits

..

2 Commits

Author SHA1 Message Date
philipp lang 3b63a73161 Fix tests
continuous-integration/drone/push Build is failing Details
2024-07-08 22:39:11 +02:00
philipp lang 4e453a73a6 Fix tests 2024-07-08 21:42:31 +02:00
3 changed files with 27 additions and 12 deletions

View File

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

View File

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

View File

@ -186,7 +186,7 @@ class PreventionTest extends TestCase
public function testItRendersSetttingMail(): void
{
Mail::fake();
app(PreventionSettings::class)->fake([
app(PreventionSettings::class)->fill([
'formmail' => EditorRequestFactory::new()->paragraphs(["lorem lala {formname} g", "{wanted}", "bbb"])->toData()
])->save();
$form = $this->createForm();
@ -203,7 +203,7 @@ class PreventionTest extends TestCase
public function testItAppendsTextOfForm(): void
{
Mail::fake();
app(PreventionSettings::class)->fake([
app(PreventionSettings::class)->fill([
'formmail' => EditorRequestFactory::new()->paragraphs(["::first::"])->toData()
])->save();
$form = $this->createForm();
@ -217,6 +217,24 @@ 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
{
$form = $this->createForm();