Fix tests
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
4e453a73a6
commit
3b63a73161
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -12,7 +12,7 @@ class EditorDataTest extends TestCase
|
|||
{
|
||||
$data = EditorRequestFactory::new()->paragraphs(['{search}'])->toData();
|
||||
|
||||
$data = $data->replaceWithList('search', ['A', 'B']);
|
||||
$data->replaceWithList('search', ['A', 'B']);
|
||||
|
||||
$this->assertEquals('A', data_get($data->blocks, '0.data.items.0.content'));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue