From 2abe061c4ff710e9989b1c03f7a5dd24359ab961 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Fri, 19 Apr 2024 17:42:59 +0200 Subject: [PATCH] Update content tests --- app/Form/Actions/FormStoreAction.php | 4 ++-- app/Form/Actions/FormUpdateAction.php | 4 ++-- app/Form/Models/Form.php | 2 ++ app/Form/Resources/FormResource.php | 4 ++-- tests/Feature/Form/FormRegisterMailTest.php | 3 ++- tests/Feature/Form/FormRequest.php | 8 ++++---- tests/Feature/Form/FormStoreActionTest.php | 8 ++++---- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/Form/Actions/FormStoreAction.php b/app/Form/Actions/FormStoreAction.php index e0e75ae0..ea9b0466 100644 --- a/app/Form/Actions/FormStoreAction.php +++ b/app/Form/Actions/FormStoreAction.php @@ -28,8 +28,8 @@ class FormStoreAction 'to' => 'required|date', 'registration_from' => 'present|nullable|date', 'registration_until' => 'present|nullable|date', - 'mail_top' => 'nullable|string', - 'mail_bottom' => 'nullable|string', + 'mail_top' => 'array', + 'mail_bottom' => 'array', 'header_image' => 'required|exclude', 'mailattachments' => 'present|array|exclude', ]; diff --git a/app/Form/Actions/FormUpdateAction.php b/app/Form/Actions/FormUpdateAction.php index 4a9ac652..0303bfbe 100644 --- a/app/Form/Actions/FormUpdateAction.php +++ b/app/Form/Actions/FormUpdateAction.php @@ -29,8 +29,8 @@ class FormUpdateAction 'to' => 'required|date', 'registration_from' => 'present|nullable|date', 'registration_until' => 'present|nullable|date', - 'mail_top' => 'nullable|string', - 'mail_bottom' => 'nullable|string', + 'mail_top' => 'array', + 'mail_bottom' => 'array', ]; } diff --git a/app/Form/Models/Form.php b/app/Form/Models/Form.php index bdb84874..2a7eadcd 100644 --- a/app/Form/Models/Form.php +++ b/app/Form/Models/Form.php @@ -29,6 +29,8 @@ class Form extends Model implements HasMedia 'config' => FormConfigData::class, 'meta' => 'json', 'description' => 'json', + 'mail_top' => 'json', + 'mail_bottom' => 'json', ]; /** @var array */ diff --git a/app/Form/Resources/FormResource.php b/app/Form/Resources/FormResource.php index b7cf0f92..ace294d1 100644 --- a/app/Form/Resources/FormResource.php +++ b/app/Form/Resources/FormResource.php @@ -77,8 +77,8 @@ class FormResource extends JsonResource 'to' => null, 'registration_from' => null, 'registration_until' => null, - 'mail_top' => null, - 'mail_bottom' => null, + 'mail_top' => [], + 'mail_bottom' => [], 'config' => null, 'header_image' => null, 'mailattachments' => [], diff --git a/tests/Feature/Form/FormRegisterMailTest.php b/tests/Feature/Form/FormRegisterMailTest.php index df38a803..3a057037 100644 --- a/tests/Feature/Form/FormRegisterMailTest.php +++ b/tests/Feature/Form/FormRegisterMailTest.php @@ -7,6 +7,7 @@ use App\Form\Mails\ConfirmRegistrationMail; use App\Form\Models\Form; use App\Form\Models\Participant; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Tests\RequestFactories\EditorRequestFactory; class FormRegisterMailTest extends FormTestCase { @@ -25,7 +26,7 @@ class FormRegisterMailTest extends FormTestCase ]) ]) - ->mailTop('mail top')->mailBottom('mail bottom') + ->mailTop(EditorRequestFactory::new()->text(10, 'mail top'))->mailBottom(EditorRequestFactory::new()->text(11, 'mail bottom')) ) ->data(['vorname' => 'Max', 'nachname' => 'Muster']) ->create(); diff --git a/tests/Feature/Form/FormRequest.php b/tests/Feature/Form/FormRequest.php index 3cb305f2..1c84b9a1 100644 --- a/tests/Feature/Form/FormRequest.php +++ b/tests/Feature/Form/FormRequest.php @@ -12,8 +12,8 @@ use Worksome\RequestFactories\RequestFactory; * @method self from(string $date) * @method self to(string $date) * @method self description(?EditorRequestFactory $description) - * @method self mailTop(string $content) - * @method self mailBottom(string $content) + * @method self mailTop(?EditorRequestFactory $content) + * @method self mailBottom(?EditorRequestFactory $content) * @method self excerpt(string $description) * @method self registrationFrom(string|null $date) * @method self registrationUntil(string|null $date) @@ -40,8 +40,8 @@ class FormRequest extends RequestFactory 'to' => $this->faker->dateTime()->format('Y-m-d H:i:s'), 'registration_from' => $this->faker->dateTime()->format('Y-m-d H:i:s'), 'registration_until' => $this->faker->dateTime()->format('Y-m-d H:i:s'), - 'mail_top' => $this->faker->text(), - 'mail_bottom' => $this->faker->text(), + 'mail_top' => EditorRequestFactory::new()->create(), + 'mail_bottom' => EditorRequestFactory::new()->create(), 'header_image' => $this->getHeaderImagePayload(str()->uuid() . '.jpg'), 'mailattachments' => [], ]; diff --git a/tests/Feature/Form/FormStoreActionTest.php b/tests/Feature/Form/FormStoreActionTest.php index 37484a2b..8770e45e 100644 --- a/tests/Feature/Form/FormStoreActionTest.php +++ b/tests/Feature/Form/FormStoreActionTest.php @@ -26,8 +26,8 @@ class FormStoreActionTest extends FormTestCase ->description($description) ->excerpt('avff') ->registrationFrom('2023-05-04 01:00:00')->registrationUntil('2023-07-07 01:00:00')->from('2023-07-07')->to('2023-07-08') - ->mailTop('Guten Tag') - ->mailBottom('Viele Grüße') + ->mailTop(EditorRequestFactory::new()->text(11, 'lala')) + ->mailBottom(EditorRequestFactory::new()->text(12, 'lalab')) ->headerImage('htzz.jpg') ->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)->forMembers(false)->hint('hhh')])]) ->fake(); @@ -39,8 +39,8 @@ class FormStoreActionTest extends FormTestCase $this->assertEquals('formname', $form->name); $this->assertEquals('avff', $form->excerpt); $this->assertEquals($description->paragraphBlock(10, 'Lorem'), $form->description); - $this->assertEquals('Guten Tag', $form->mail_top); - $this->assertEquals('Viele Grüße', $form->mail_bottom); + $this->assertEquals(json_decode('{"time":1,"blocks":[{"id":11,"type":"paragraph","data":{"text":"lala"}}],"version":"1.0"}', true), $form->mail_top); + $this->assertEquals(json_decode('{"time":1,"blocks":[{"id":12,"type":"paragraph","data":{"text":"lalab"}}],"version":"1.0"}', true), $form->mail_bottom); $this->assertEquals('2023-05-04 01:00', $form->registration_from->format('Y-m-d H:i')); $this->assertEquals('2023-07-07 01:00', $form->registration_until->format('Y-m-d H:i')); $this->assertEquals('2023-07-07', $form->from->format('Y-m-d'));