2024-02-08 21:04:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Form;
|
|
|
|
|
|
|
|
use App\Form\Fields\CheckboxesField;
|
2024-02-08 23:09:51 +01:00
|
|
|
use App\Form\Fields\DateField;
|
2024-02-08 21:04:00 +01:00
|
|
|
use App\Form\Fields\DropdownField;
|
2024-02-08 23:09:51 +01:00
|
|
|
use App\Form\Fields\GroupField;
|
2024-02-08 21:04:00 +01:00
|
|
|
use App\Form\Fields\TextField;
|
|
|
|
use App\Form\Models\Form;
|
|
|
|
use App\Form\Models\Participant;
|
2024-02-08 23:09:51 +01:00
|
|
|
use App\Group;
|
2024-02-08 21:04:00 +01:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class ParticipantIndexActionTest extends TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItShowsParticipantsAndColumns(): void
|
|
|
|
{
|
|
|
|
$this->login()->loginNami()->withoutExceptionHandling();
|
2024-02-08 23:09:51 +01:00
|
|
|
$group = Group::factory()->innerName('Stamm')->create();
|
2024-02-08 21:04:00 +01:00
|
|
|
$form = Form::factory()
|
2024-02-09 23:22:49 +01:00
|
|
|
->has(Participant::factory()->data(['vorname' => 'Max', 'select' => ['A', 'B'], 'stufe' => 'Pfadfinder', 'test1' => '', 'test2' => '', 'test3' => '', 'birthday' => '1991-04-20', 'bezirk' => $group->id]))
|
2024-02-08 21:04:00 +01:00
|
|
|
->sections([
|
|
|
|
FormtemplateSectionRequest::new()->fields([
|
|
|
|
FormtemplateFieldRequest::type(TextField::class)->name('Vorname')->key('vorname'),
|
|
|
|
FormtemplateFieldRequest::type(CheckboxesField::class)->key('select')->options(['A', 'B', 'C']),
|
|
|
|
FormtemplateFieldRequest::type(DropdownField::class)->key('stufe')->options(['Wölfling', 'Jungpfadfinder', 'Pfadfinder']),
|
2024-02-08 23:09:51 +01:00
|
|
|
FormtemplateFieldRequest::type(TextField::class)->name('Test 1')->key('test1'),
|
|
|
|
FormtemplateFieldRequest::type(TextField::class)->name('Test 2')->key('test2'),
|
|
|
|
FormtemplateFieldRequest::type(TextField::class)->name('Test 3')->key('test3'),
|
|
|
|
FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->key('birthday'),
|
|
|
|
FormtemplateFieldRequest::type(GroupField::class)->name('bezirk')->key('bezirk'),
|
2024-02-08 21:04:00 +01:00
|
|
|
]),
|
|
|
|
])
|
|
|
|
->create();
|
|
|
|
|
|
|
|
$this->callFilter('form.participant.index', [], ['form' => $form])
|
|
|
|
->assertOk()
|
|
|
|
->assertJsonPath('data.0.vorname', 'Max')
|
2024-02-09 23:22:49 +01:00
|
|
|
->assertJsonPath('data.0.vorname_display', 'Max')
|
2024-02-08 21:04:00 +01:00
|
|
|
->assertJsonPath('data.0.stufe', 'Pfadfinder')
|
2024-02-08 23:09:51 +01:00
|
|
|
->assertJsonPath('data.0.bezirk', $group->id)
|
2024-02-09 23:22:49 +01:00
|
|
|
->assertJsonPath('data.0.bezirk_display', 'Stamm')
|
|
|
|
->assertJsonPath('data.0.birthday_display', '20.04.1991')
|
2024-02-08 23:09:51 +01:00
|
|
|
->assertJsonPath('data.0.birthday', '1991-04-20')
|
2024-02-09 23:22:49 +01:00
|
|
|
->assertJsonPath('data.0.select', ['A', 'B'])
|
|
|
|
->assertJsonPath('data.0.select_display', 'A, B')
|
2024-02-08 21:04:00 +01:00
|
|
|
->assertJsonPath('meta.columns.0.name', 'Vorname')
|
|
|
|
->assertJsonPath('meta.columns.0.base_type', class_basename(TextField::class))
|
2024-02-08 23:09:51 +01:00
|
|
|
->assertJsonPath('meta.columns.0.id', 'vorname')
|
2024-02-09 23:22:49 +01:00
|
|
|
->assertJsonPath('meta.columns.6.display_attribute', 'birthday_display')
|
|
|
|
->assertJsonPath('meta.columns.0.display_attribute', 'vorname_display')
|
2024-02-08 23:09:51 +01:00
|
|
|
->assertJsonPath('meta.active_columns', ['vorname', 'select', 'stufe', 'test1']);
|
2024-02-08 21:04:00 +01:00
|
|
|
}
|
|
|
|
}
|