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;
|
2020-07-30 17:47:40 +02:00
|
|
|
use App\Utils\Traits\MakesInvoiceValues;
|
2020-07-29 13:37:05 +02:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
class ExampleIntegrationTest extends TestCase
|
|
|
|
|
{
|
2020-07-30 17:47:40 +02:00
|
|
|
use MakesInvoiceValues;
|
|
|
|
|
|
2020-07-29 13:37:05 +02:00
|
|
|
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-30 17:47:40 +02:00
|
|
|
|
|
|
|
|
$product_table_columns = json_decode(
|
|
|
|
|
json_encode($invoice->company->settings->pdf_variables), 1
|
|
|
|
|
)['product_columns'];
|
2020-07-29 13:37:05 +02:00
|
|
|
|
|
|
|
|
$state = [
|
2020-07-30 17:47:40 +02:00
|
|
|
'template' => $design->elements([
|
|
|
|
|
'client' => $invoice->client,
|
|
|
|
|
'invoice' => $invoice,
|
|
|
|
|
'product-table-columns' => $product_table_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
|
|
|
}
|
|
|
|
|
}
|