2022-12-06 21:25:47 +01:00
|
|
|
<?php
|
|
|
|
|
2023-04-18 22:08:45 +02:00
|
|
|
namespace Tests\Feature\Invoice;
|
|
|
|
|
|
|
|
use App\Invoice\BillDocument;
|
2023-11-30 23:54:16 +01:00
|
|
|
use App\Invoice\BillKind;
|
|
|
|
use App\Invoice\Invoice;
|
|
|
|
use App\Invoice\Queries\BillKindQuery;
|
2023-04-18 22:08:45 +02:00
|
|
|
use App\Invoice\Queries\InvoiceMemberQuery;
|
2022-12-06 21:25:47 +01:00
|
|
|
use App\Member\Member;
|
|
|
|
use App\Payment\Payment;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2023-11-30 23:54:16 +01:00
|
|
|
class BillRememberDocumentTest extends TestCase
|
2022-12-06 21:25:47 +01:00
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testItCreatesOneFileForFamilyMembers(): void
|
|
|
|
{
|
2023-11-30 23:54:16 +01:00
|
|
|
Member::factory()
|
2022-12-06 21:25:47 +01:00
|
|
|
->defaults()
|
2023-11-30 23:54:16 +01:00
|
|
|
->postBillKind()
|
2022-12-06 21:25:47 +01:00
|
|
|
->state(['firstname' => 'Max1', 'lastname' => '::lastname::', 'address' => '::address::', 'zip' => '12345', 'location' => '::location::'])
|
|
|
|
->has(Payment::factory()->notPaid()->nr('nr1'))
|
|
|
|
->create();
|
|
|
|
Member::factory()
|
|
|
|
->defaults()
|
2023-11-30 23:54:16 +01:00
|
|
|
->postBillKind()
|
2022-12-06 21:25:47 +01:00
|
|
|
->state(['firstname' => 'Max2', 'lastname' => '::lastname::', 'address' => '::address::', 'zip' => '12345', 'location' => '::location::'])
|
|
|
|
->has(Payment::factory()->notPaid()->nr('nr2'))
|
|
|
|
->create();
|
|
|
|
|
2023-11-30 23:54:16 +01:00
|
|
|
$this->assertCount(2, $this->query(BillDocument::class)->getMembers()->first());
|
2022-12-06 21:25:47 +01:00
|
|
|
}
|
|
|
|
|
2023-11-30 23:54:16 +01:00
|
|
|
/**
|
|
|
|
* @param class-string<Invoice> $type
|
|
|
|
*/
|
|
|
|
private function query(string $type): InvoiceMemberQuery
|
2022-12-07 00:40:53 +01:00
|
|
|
{
|
2023-11-30 23:54:16 +01:00
|
|
|
return (new BillKindQuery(BillKind::POST))->type($type);
|
2022-12-07 00:40:53 +01:00
|
|
|
}
|
2022-12-06 21:25:47 +01:00
|
|
|
}
|