2020-07-29 13:37:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\PdfMaker;
|
|
|
|
|
|
|
|
use App\Models\Invoice;
|
2020-08-07 14:30:56 +02:00
|
|
|
use App\Services\PdfMaker\Designs\Plain;
|
2020-07-29 13:37:05 +02:00
|
|
|
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();
|
|
|
|
|
2020-08-07 13:55:02 +02:00
|
|
|
$engine = new HtmlEngine(null, $invitation, 'invoice');
|
2020-08-07 14:30:56 +02:00
|
|
|
$design = new Plain();
|
2020-07-30 17:47:40 +02:00
|
|
|
|
|
|
|
$product_table_columns = json_decode(
|
2020-08-04 17:32:28 +02:00
|
|
|
json_encode($invoice->company->settings->pdf_variables),
|
|
|
|
1
|
2020-07-30 17:47:40 +02:00
|
|
|
)['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,
|
2020-08-05 11:52:01 +02:00
|
|
|
'entity' => $invoice,
|
2020-07-30 17:47:40 +02:00
|
|
|
'product-table-columns' => $product_table_columns,
|
|
|
|
]),
|
2020-07-29 13:37:05 +02:00
|
|
|
'variables' => $engine->generateLabelsAndValues(),
|
|
|
|
];
|
|
|
|
|
2020-08-07 16:11:10 +02:00
|
|
|
$maker = new PdfMaker($state, 'product');
|
2020-07-29 13:37:05 +02:00
|
|
|
|
|
|
|
$maker
|
2020-08-07 14:30:56 +02:00
|
|
|
->design(Plain::class)
|
2020-07-29 13:37:05 +02:00
|
|
|
->build();
|
|
|
|
|
2020-08-04 17:32:28 +02:00
|
|
|
exec('echo "" > storage/logs/laravel.log');
|
|
|
|
|
|
|
|
info($maker->getCompiledHTML(true));
|
|
|
|
|
|
|
|
$this->assertTrue(true);
|
2020-07-29 13:37:05 +02:00
|
|
|
}
|
|
|
|
}
|