adrema/tests/Feature/Form/ParticipantStoreActionTest.php

44 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2024-07-13 18:24:43 +02:00
<?php
namespace Tests\Feature\Form;
use App\Form\Actions\ExportSyncAction;
use App\Form\Models\Form;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Queue;
class ParticipantStoreActionTest extends FormTestCase
{
use DatabaseTransactions;
public function testItStoresParticipant(): void
{
Queue::fake();
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()->fields([
$this->textField('vorname')->name('Vorname')->required(true),
])
->create();
$this->postJson(route('form.participant.store', ['form' => $form->id]), ['vorname' => 'Jane'])
->assertOk();
$this->assertEquals('Jane', $form->participants->first()->data['vorname']);
ExportSyncAction::assertPushed();
}
public function testItHasValidation(): void
{
Queue::fake();
$this->login()->loginNami();
$form = Form::factory()->fields([
$this->textField('vorname')->name('Vorname')->required(true),
])
->create();
$this->postJson(route('form.participant.store', ['form' => $form->id]), ['vorname' => ''])
->assertJsonValidationErrors(['vorname' => 'Vorname ist erforderlich.']);
}
}