116 lines
3.5 KiB
PHP
116 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Service\Pdf;
|
|
|
|
use App\Entity\Application;
|
|
use App\Entity\Assignment;
|
|
use App\Entity\Destination;
|
|
use App\Entity\Disposition;
|
|
use App\Entity\Embeddable\Address;
|
|
use App\Entity\Embeddable\BankAccount;
|
|
use App\Entity\Embeddable\Communication;
|
|
use App\Entity\JobProfile;
|
|
use App\Entity\Teamer;
|
|
use App\Entity\Upload;
|
|
use App\Entity\User;
|
|
use App\Service\Pdf\InvoiceApprover;
|
|
use App\Service\Pdf\InvoiceRenderer;
|
|
use App\Service\Pdf\Pdf;
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
class InvoiceRendererTest extends WebTestCase
|
|
{
|
|
public function testRendersInvoice(): void
|
|
{
|
|
$projectDir = static::getContainer()->getParameter('kernel.project_dir');
|
|
$translator = $this->createMock(TranslatorInterface::class);
|
|
/** @var TranslatorInterface $translator */
|
|
$renderer = new InvoiceRenderer($translator, ['project_dir' => $projectDir]);
|
|
|
|
$address = new Address();
|
|
$address
|
|
->setStreet('Testweg 1')
|
|
->setCity('Teststadt')
|
|
->setPostCode('12345')
|
|
;
|
|
|
|
$communication = new Communication();
|
|
$communication
|
|
->setEmail('[email protected]')
|
|
->setPhone('123456789')
|
|
->setMobile('0123-456789')
|
|
;
|
|
|
|
$bankAccount = new BankAccount();
|
|
$bankAccount
|
|
->setIban('DE88100900001234567892')
|
|
->setBic('ABCDEF1')
|
|
->setBank('ACME Bank')
|
|
->setHolder('Isolde Duschen')
|
|
;
|
|
|
|
$teamer = new Teamer();
|
|
$teamer
|
|
->setFirstName('Isolde')
|
|
->setLastName('Duschen')
|
|
->setTaxId('123/456/789')
|
|
->setAddress($address)
|
|
->setCommunication($communication)
|
|
->setBankAccount($bankAccount)
|
|
;
|
|
|
|
$destination = new Destination();
|
|
$destination
|
|
->setProduct('Skireise')
|
|
->setHotel('Unterkunft')
|
|
->setCode('ABC123')
|
|
->setDateFrom(new \DateTimeImmutable('2023-12-01'))
|
|
->setDateTo(new \DateTimeImmutable('2023-12-08'))
|
|
->setCostUnit('200')
|
|
;
|
|
|
|
$jobProfile = new JobProfile();
|
|
$jobProfile->setName('Allrounder');
|
|
$jobProfile->setCostUnit('300');
|
|
|
|
$contact = new User();
|
|
$contact
|
|
->setFirstName('Carmen')
|
|
->setLastName('Bär')
|
|
->setEmail('[email protected]')
|
|
;
|
|
|
|
$assignment = new Assignment();
|
|
$assignment
|
|
->setDestination($destination)
|
|
->setJobProfile($jobProfile)
|
|
->setContact($contact)
|
|
;
|
|
|
|
$application = new Application($assignment, $teamer);
|
|
$disposition = new Disposition($application);
|
|
|
|
$pdf = $renderer->render($disposition);
|
|
$this->assertInstanceOf(Pdf::class, $pdf);
|
|
|
|
$pdf->Output('F', $projectDir.'/uploads/invoice/a/abcdef0123456789.pdf');
|
|
|
|
$invoice = new Upload();
|
|
$invoice
|
|
->setType(Upload::TYPE_INVOICE)
|
|
->setMimeType('application/pdf')
|
|
->setFilename('abcdef0123456789.pdf')
|
|
->setApprovedBy('FOO')
|
|
->setApprovedAt(new \DateTimeImmutable())
|
|
->setStatus(Upload::STATUS_PAID)
|
|
;
|
|
$disposition->addDocument($invoice);
|
|
|
|
/** @var TranslatorInterface $translator */
|
|
$approver = new InvoiceApprover($translator, ['project_dir' => $projectDir]);
|
|
$pdf = $approver->render($disposition);
|
|
$this->assertInstanceOf(Pdf::class, $pdf);
|
|
}
|
|
}
|