Testing PDF mocks

This commit is contained in:
David Bomba 2023-02-25 12:08:34 +11:00
parent 55cc1e46ce
commit 7772da95d3
4 changed files with 24 additions and 5 deletions

View File

@ -561,9 +561,9 @@ class PdfBuilder
$data[$key][$table_type.".{$_table_type}4"] = strlen($item->custom_value4) >= 1 ? $helpers->formatCustomFieldValue($this->service->company->custom_fields, "{$_table_type}4", $item->custom_value4, $this->service->config->currency_entity) : '';
if ($item->quantity > 0 || $item->cost > 0) {
$data[$key][$table_type.'.quantity'] = Number::formatValueNoTrailingZeroes($item->quantity, $this->service->config->currency_entity);
$data[$key][$table_type.'.quantity'] = $this->service->config->formatMoney($item->quantity);
$data[$key][$table_type.'.unit_cost'] = Number::formatMoneyNoRounding($item->cost, $this->service->config->currency_entity);
$data[$key][$table_type.'.unit_cost'] = $this->service->config->formatMoney($item->cost);
$data[$key][$table_type.'.cost'] = $this->service->config->formatMoney($item->cost);

View File

@ -142,7 +142,7 @@ class PdfConfiguration
*
* @return self
*/
private function setPdfVariables() :self
public function setPdfVariables() :self
{
$default = (array) CompanySettings::getEntityVariableDefaults();

View File

@ -43,7 +43,7 @@ class PdfMock
private function getTaxMap()
{
return collect( ['name' => 'GST', 'total' => 10]);
return collect( [['name' => 'GST', 'total' => 10]]);
}

View File

@ -13,9 +13,11 @@
namespace Tests\Pdf;
use Tests\TestCase;
use App\Models\Design;
use App\Models\Country;
use App\Models\Invoice;
use App\Models\Currency;
use App\Services\Pdf\PdfBuilder;
use Tests\MockAccountData;
use App\Services\Pdf\PdfMock;
use Beganovich\Snappdf\Snappdf;
@ -71,8 +73,25 @@ class PdfmockTest extends TestCase
$pdf_config->entity_design_id = 'invoice_design_id';
$pdf_config->settings_object = $mock->client;
$pdf_config->entity_string = 'invoice';
$pdf_config->settings = $pdf_config->service->company->settings;
$pdf_config->settings = (object)$pdf_config->service->company->settings;
$pdf_config->setPdfVariables();
$pdf_config->design = Design::find(2);
$pdf_config->currency_entity = $mock->client;
$pdf_service->config = $pdf_config;
$pdf_designer = (new \App\Services\Pdf\PdfDesigner($pdf_service))->build();
$pdf_service->designer = $pdf_designer;
$pdf_service->html_variables = $this->getStubVariables();
$pdf_builder = (new PdfBuilder($pdf_service))->build();
$pdf_service->builder = $pdf_builder;
$this->assertNotNull($pdf_config);
}
private function getStubVariables()
{
return ['values' => [], 'labels' => []];
}
}