adrema/tests/Feature/Form/ParticipantExportActionTest...

40 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2024-05-27 21:08:09 +02:00
<?php
namespace Tests\Feature\Form;
use App\Form\Models\Form;
use App\Form\Models\Participant;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Storage;
class ParticipantExportActionTest extends FormTestCase
{
use DatabaseTransactions;
public function testItShowsParticipantsAndColumns(): void
{
Storage::fake('temp');
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()
->has(Participant::factory()->data(['stufe' => 'Pfadfinder', 'vorname' => 'Max', 'select' => ['A', 'B']]))
->sections([
FormtemplateSectionRequest::new()->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();
2024-07-16 00:05:27 +02:00
$this->get(route('form.export', ['form' => $form]))->assertDownload('tn-zem-2024.xlsx');
$contents = Storage::disk('temp')->get('tn-zem-2024.xlsx');
$this->assertExcelContent('Max', $contents);
$this->assertExcelContent('A, B', $contents);
$this->assertExcelContent('Pfadfinder', $contents);
$this->assertExcelContent('Stufe', $contents);
$this->assertExcelContent('Abcselect', $contents);
2024-05-27 21:08:09 +02:00
}
}