adrema/tests/Feature/Pdf/EfzTest.php

59 lines
2.0 KiB
PHP
Raw Normal View History

2022-03-20 16:33:56 +01:00
<?php
namespace Tests\Feature\Pdf;
2022-10-28 12:01:04 +02:00
use App\Efz\EfzDocument;
2022-03-20 16:33:56 +01:00
use App\Member\Member;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
2022-10-28 12:01:04 +02:00
use Zoomyboy\Tex\Tex;
2022-03-20 16:33:56 +01:00
class EfzTest extends TestCase
{
use DatabaseTransactions;
public function testItCreatesAEfzPdfFile(): void
{
2022-10-28 12:01:04 +02:00
Tex::fake();
$this->withoutExceptionHandling()->login()->withNamiSettings();
$member = Member::factory()->defaults()->create([
'firstname' => 'Max',
'lastname' => 'Muster',
'address' => 'Itt 4',
'zip' => '12345',
'location' => 'Solingen',
'birthday' => '2015-02-11',
'nami_id' => 552,
]);
$response = $this->get("/member/{$member->id}/efz");
$response->assertOk();
$response->assertHeader('Content-Disposition', 'inline; filename="efz-fuer-max-muster.pdf"');
Tex::assertCompiled(EfzDocument::class, fn ($document) => 'Max Muster' === $document->name
&& 'efz-fuer-max-muster' === $document->basename()
&& 'geb. am 11.02.2015, wohnhaft in Solingen' === $document->secondLine
&& now()->format('d.m.Y') === $document->now
&& [
'Max Muster',
'Itt 4',
'12345 Solingen',
'Mglnr.: 552',
] === $document->sender->values()
);
}
public function testItReallyCreatesAEfzPdfFile(): void
{
Tex::spy();
2022-08-30 23:43:54 +02:00
$this->withoutExceptionHandling()->login()->withNamiSettings();
2022-03-20 16:33:56 +01:00
$member = Member::factory()->defaults()->create(['firstname' => 'Max', 'lastname' => 'Muster']);
$response = $this->get("/member/{$member->id}/efz");
$response->assertOk();
$response->assertHeader('Content-Disposition', 'inline; filename="efz-fuer-max-muster.pdf"');
2022-10-28 12:01:04 +02:00
Tex::assertCompiled(EfzDocument::class, fn ($document) => $document->hasContent('Absender:') && $document->hasContent('Max Muster'));
2022-03-20 16:33:56 +01:00
}
}