adrema/tests/Feature/Member/ExportCsvActionTest.php

34 lines
1.1 KiB
PHP
Raw Normal View History

2023-03-14 23:55:50 +01:00
<?php
namespace Tests\Feature\Member;
use App\Member\Member;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class ExportCsvActionTest extends TestCase
{
use DatabaseTransactions;
/**
* A basic feature test example.
*/
public function testItExportsACsvFile(): void
{
Storage::fake('temp');
$this->withoutExceptionHandling()->login()->loginNami();
2023-03-15 00:08:20 +01:00
Member::factory()->defaults()->postBillKind()->create(['firstname' => 'Jane', 'main_phone' => '+49 176 70343221']);
2023-03-14 23:55:50 +01:00
Member::factory()->defaults()->emailBillKind()->create(['firstname' => 'Max']);
$response = $this->callFilter('member-export', ['bill_kind' => 'Post']);
$response->assertDownload('mitglieder.csv');
$contents = Storage::disk('temp')->get('mitglieder.csv');
$this->assertTrue(str_contains($contents, 'Jane'));
2023-03-15 00:08:20 +01:00
$this->assertTrue(str_contains($contents, '+49 176 70343221'));
2023-03-14 23:55:50 +01:00
$this->assertFalse(str_contains($contents, 'Max'));
}
}