mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 04:44:32 -04:00
Fixes for tests
This commit is contained in:
parent
d211fb3afa
commit
0b16b2ac9c
@ -154,7 +154,7 @@ class CompanyTransformer extends EntityTransformer
|
|||||||
'invoice_task_timelog' => (bool) $company->invoice_task_timelog,
|
'invoice_task_timelog' => (bool) $company->invoice_task_timelog,
|
||||||
'auto_start_tasks' => (bool) $company->auto_start_tasks,
|
'auto_start_tasks' => (bool) $company->auto_start_tasks,
|
||||||
'invoice_task_documents' => (bool) $company->invoice_task_documents,
|
'invoice_task_documents' => (bool) $company->invoice_task_documents,
|
||||||
'use_credits_payment' => 'always', //todo remove
|
// 'use_credits_payment' => 'always', //todo remove
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,18 +12,26 @@ namespace Tests\Integration;
|
|||||||
|
|
||||||
use App\Designs\Bold;
|
use App\Designs\Bold;
|
||||||
use App\Designs\Designer;
|
use App\Designs\Designer;
|
||||||
|
use App\Models\Credit;
|
||||||
use App\Models\Design;
|
use App\Models\Design;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Quote;
|
||||||
|
use App\Models\RecurringInvoice;
|
||||||
|
use App\Utils\HtmlEngine;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Utils\Traits\MakesInvoiceHtml;
|
use App\Utils\Traits\MakesInvoiceHtml;
|
||||||
use Tests\MockAccountData;
|
use Tests\MockAccountData;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use App\Services\PdfMaker\Design as PdfDesignModel;
|
||||||
|
use App\Services\PdfMaker\Design as PdfMakerDesign;
|
||||||
|
use App\Services\PdfMaker\PdfMaker as PdfMakerService;
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
class HtmlGenerationTest extends TestCase
|
class HtmlGenerationTest extends TestCase
|
||||||
{
|
{
|
||||||
use MockAccountData;
|
use MockAccountData;
|
||||||
use MakesInvoiceHtml;
|
use MakesHash;
|
||||||
|
|
||||||
public function setUp() :void
|
public function setUp() :void
|
||||||
{
|
{
|
||||||
@ -34,12 +42,58 @@ class HtmlGenerationTest extends TestCase
|
|||||||
|
|
||||||
public function testHtmlOutput()
|
public function testHtmlOutput()
|
||||||
{
|
{
|
||||||
$design = Design::find(3);
|
$html = $this->generateHtml($this->invoice);
|
||||||
|
|
||||||
$designer = new Designer($this->invoice, $design, $this->invoice->client->getSetting('pdf_variables'), 'invoice');
|
|
||||||
|
|
||||||
$html = $this->generateEntityHtml($designer, $this->invoice);
|
|
||||||
|
|
||||||
$this->assertNotNull($html);
|
$this->assertNotNull($html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function generateHtml($entity)
|
||||||
|
{
|
||||||
|
$entity_design_id = '';
|
||||||
|
|
||||||
|
if($entity instanceof Invoice || $entity instanceof RecurringInvoice){
|
||||||
|
$entity_design_id = 'invoice_design_id';
|
||||||
|
}
|
||||||
|
elseif($entity instanceof Quote){
|
||||||
|
$entity_design_id = 'quote_design_id';
|
||||||
|
}
|
||||||
|
elseif($entity instanceof Credit){
|
||||||
|
$entity_design_id = 'credit_design_id';
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity_design_id = $entity->design_id ? $entity->design_id : $this->decodePrimaryKey($entity->client->getSetting($entity_design_id));
|
||||||
|
|
||||||
|
$design = Design::find($entity_design_id);
|
||||||
|
$html = new HtmlEngine($entity->invitations->first());
|
||||||
|
|
||||||
|
if ($design->is_custom) {
|
||||||
|
$options = [
|
||||||
|
'custom_partials' => json_decode(json_encode($design->design), true)
|
||||||
|
];
|
||||||
|
$template = new PdfMakerDesign(PdfDesignModel::CUSTOM, $options);
|
||||||
|
} else {
|
||||||
|
$template = new PdfMakerDesign(strtolower($design->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
$state = [
|
||||||
|
'template' => $template->elements([
|
||||||
|
'client' => $entity->client,
|
||||||
|
'entity' => $entity,
|
||||||
|
'pdf_variables' => (array) $entity->company->settings->pdf_variables,
|
||||||
|
'products' => $design->design->product,
|
||||||
|
]),
|
||||||
|
'variables' => $html->generateLabelsAndValues(),
|
||||||
|
'options' => [
|
||||||
|
'all_pages_header' => $entity->client->getSetting('all_pages_header'),
|
||||||
|
'all_pages_footer' => $entity->client->getSetting('all_pages_footer'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$maker = new PdfMakerService($state);
|
||||||
|
|
||||||
|
return $maker->design($template)
|
||||||
|
->build()
|
||||||
|
->getCompiledHTML(true);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user