2024-07-12 20:15:24 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Form;
|
|
|
|
|
2024-07-13 17:54:23 +02:00
|
|
|
use App\Form\Actions\ExportSyncAction;
|
2024-07-12 20:15:24 +02:00
|
|
|
use App\Form\Models\Form;
|
|
|
|
use App\Form\Models\Participant;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2024-07-13 17:54:23 +02:00
|
|
|
use Illuminate\Support\Facades\Queue;
|
2024-07-12 20:15:24 +02:00
|
|
|
|
|
|
|
class ParticipantUpdateActionTest extends FormTestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItUpdatesParticipant(): void
|
|
|
|
{
|
2024-07-13 17:54:23 +02:00
|
|
|
Queue::fake();
|
2024-07-12 20:15:24 +02:00
|
|
|
$this->login()->loginNami()->withoutExceptionHandling();
|
2024-07-13 17:54:23 +02:00
|
|
|
$participant = Participant::factory()->data(['vorname' => 'Max'])
|
|
|
|
->for(Form::factory()->fields([
|
|
|
|
$this->textField('vorname')->name('Vorname'),
|
2024-07-12 20:15:24 +02:00
|
|
|
]))
|
|
|
|
->create();
|
|
|
|
|
2024-07-13 17:54:23 +02:00
|
|
|
$this->patchJson(route('participant.update', ['participant' => $participant->id]), ['vorname' => 'Jane'])
|
2024-07-12 20:15:24 +02:00
|
|
|
->assertOk();
|
|
|
|
|
|
|
|
$this->assertEquals('Jane', $participant->fresh()->data['vorname']);
|
2024-07-13 17:54:23 +02:00
|
|
|
ExportSyncAction::assertPushed();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testItHasValidation(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami();
|
|
|
|
$participant = Participant::factory()->data(['vorname' => 'Max', 'select' => ['A', 'B']])
|
|
|
|
->for(Form::factory()->fields([
|
|
|
|
$this->textField('vorname')->name('Vorname')->required(true),
|
|
|
|
]))
|
|
|
|
->create();
|
|
|
|
|
|
|
|
$this->patchJson(route('participant.update', ['participant' => $participant->id]), ['vorname' => ''])
|
|
|
|
->assertJsonValidationErrors(['vorname' => 'Vorname ist erforderlich.']);
|
2024-07-12 20:15:24 +02:00
|
|
|
}
|
|
|
|
}
|