Fix tests
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2025-11-12 03:30:38 +01:00
parent ac88df2cad
commit 56af6f4cbf
3 changed files with 21 additions and 8 deletions

View File

@ -73,7 +73,7 @@ class CreateExcelDocumentAction
public function rowsFor(Collection $participants): array {
return $participants->map(fn ($participant) => $participant->getFields()->presentValues()
->put('Abgemeldet am', $participant->cancelled_at?->format('d.m.Y H:i:s') ?: '')
->prepend('ID', $participant->id)
->prepend((string) $participant->id, 'ID')
)->toArray();
}

View File

@ -111,7 +111,7 @@ class FieldCollection extends Collection
*/
public function presentValues(): Collection
{
return $this->mapWithKeys(fn ($field) => [$field->name => $field->present()]);
return $this->mapWithKeys(fn ($field) => [$field->name => $field->presentRaw()]);
}
public function hasSpecialType(SpecialType $specialType): bool

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Form;
use DB;
use App\Form\Models\Form;
use App\Form\Models\Participant;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -20,15 +21,14 @@ it('testItShowsParticipantsAndColumns', function () {
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()
->has(Participant::factory()->data(['stufe' => 'Pfadfinder', 'vorname' => 'Max', 'select' => ['A', 'B']]))
->sections([
FormtemplateSectionRequest::new()->fields([
->fields([
$this->textField('vorname')->name('Vorname'),
$this->checkboxesField('select')->name('Abcselect')->options(['A', 'B', 'C']),
$this->dropdownField('stufe')->name('Stufe')->options(['Wölfling', 'Jungpfadfinder', 'Pfadfinder']),
]),
])
->name('ZEM 2024')
->create();
DB::table('participants')->where('id', $form->participants->first()->id)->update(['id' => 9909]);
$this->get(route('form.export', ['form' => $form]))->assertDownload('tn-zem-2024.xlsx');
$contents = Storage::disk('temp')->get('tn-zem-2024.xlsx');
@ -37,4 +37,17 @@ it('testItShowsParticipantsAndColumns', function () {
$this->assertExcelContent('Pfadfinder', $contents);
$this->assertExcelContent('Stufe', $contents);
$this->assertExcelContent('Abcselect', $contents);
$this->assertExcelContent('9909', $contents);
});
it('shows cancelled at', function () {
Storage::fake('temp');
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()->name('ZEM 2024')
->has(Participant::factory()->state(['cancelled_at' => now()->subWeek()]))
->create();
$this->get(route('form.export', ['form' => $form]))->assertDownload('tn-zem-2024.xlsx');
$contents = Storage::disk('temp')->get('tn-zem-2024.xlsx');
$this->assertExcelContent(now()->subWeek()->format('d.m.Y'), $contents);
});