2020-07-29 13:37:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\Feature\PdfMaker;
|
|
|
|
|
|
2020-07-30 16:43:57 +02:00
|
|
|
use App\Models\Design;
|
2020-07-29 13:37:05 +02:00
|
|
|
use App\Models\Invoice;
|
|
|
|
|
use App\Services\PdfMaker\Designs\Plain;
|
|
|
|
|
use App\Services\PdfMaker\PdfMaker;
|
|
|
|
|
use App\Utils\HtmlEngine;
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
class ExampleIntegrationTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
public function testExample()
|
|
|
|
|
{
|
|
|
|
|
$invoice = Invoice::first();
|
|
|
|
|
$invitation = $invoice->invitations()->first();
|
|
|
|
|
|
|
|
|
|
$engine = new HtmlEngine($invitation, 'invoice');
|
2020-07-30 16:43:57 +02:00
|
|
|
$design = new Plain();
|
|
|
|
|
|
2020-07-29 13:37:05 +02:00
|
|
|
|
|
|
|
|
$state = [
|
2020-07-30 16:43:57 +02:00
|
|
|
'template' => $design->elements(json_decode(json_encode($invoice->company->settings->pdf_variables), 1)['product_columns']),
|
2020-07-29 13:37:05 +02:00
|
|
|
'variables' => $engine->generateLabelsAndValues(),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$maker = new PdfMaker($state);
|
|
|
|
|
|
|
|
|
|
$maker
|
|
|
|
|
->design(Plain::class)
|
|
|
|
|
->build();
|
|
|
|
|
|
2020-07-30 16:43:57 +02:00
|
|
|
info($maker->getCompiledHTML());
|
2020-07-29 13:37:05 +02:00
|
|
|
}
|
|
|
|
|
}
|