Feat: Impmlement invoice pdf rendering
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?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\User;
|
||||
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);
|
||||
$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'))
|
||||
;
|
||||
|
||||
$jobProfile = new JobProfile();
|
||||
$jobProfile->setName('Allrounder');
|
||||
|
||||
$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.'/temp/Honorarnote.pdf');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user