<?php
declare(strict_types=1);
namespace Tests\Adawolfa\Fucktura\Entity;
use Adawolfa\Fucktura\Entity\Invoice;
use Adawolfa\Fucktura\I18n\Currency;
use Adawolfa\Fucktura\I18n\Locale;
use Tests\Adawolfa\Fucktura\TestCase;
final class InvoiceTest extends TestCase
{
public function testInvoice(): void
{
$em = $this->getEntityManager();
$ef = $this->getEntityFactory();
$invoice = $ef->createInvoice(
$ef->createParty(
$ef->createInfo('Vendor'),
$ef->createAddress(street: 'Vendor street')
),
$ef->createParty(
$ef->createInfo('Customer'),
$ef->createAddress(street: 'Customer street')
),
);
$this->assertSame('0.0000', $invoice->totalPrice);
$this->assertNull($invoice->blob);
$invoice->blob = 'foo';
$this->assertSame('foo', $invoice->blob);
$ef->createInvoiceLine($invoice, 'Line 1', '5', '1');
$ef->createInvoiceLine($invoice, 'Line 2', '1', '5');
$em->clear();
$invoice = $em->find(Invoice::class, 1);
$this->assertSame(1, $invoice->id);
$this->assertSame('123456', $invoice->number);
$this->assertSame('E2587F23-8BBD-4D96-906A-BE5A14D063AB', $invoice->uuid);
$this->assertSame('Vendor', $invoice->vendor->name);
$this->assertSame('Vendor street', $invoice->vendorAddress->street);
$this->assertSame('Customer', $invoice->customer->name);
$this->assertSame('Customer street', $invoice->customerAddress->street);
$this->assertSame('2022-01-01', $invoice->issuedAt->format('Y-m-d'));
$this->assertSame('2022-01-15', $invoice->dueAt->format('Y-m-d'));
$this->assertSame(Locale::cs_CZ, $invoice->locale);
$this->assertSame(Currency::CZK, $invoice->currency);
$this->assertSame('12345678', $invoice->bankAccount->number);
$this->assertSame('10.0000', $invoice->totalPrice);
$this->assertSame('foo', $invoice->blob);
$this->assertSame('foo', $invoice->blob);
}
}