mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 08:21:34 +02:00
Testing PDF mocks
This commit is contained in:
parent
620f3a32e1
commit
55cc1e46ce
@ -12,7 +12,10 @@
|
||||
namespace App\Services\Pdf;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceInvitation;
|
||||
|
||||
class PdfMock
|
||||
{
|
||||
@ -27,10 +30,25 @@ class PdfMock
|
||||
|
||||
$mock = Invoice::factory()->make();
|
||||
$mock->client = Client::factory()->make();
|
||||
$mock->tax_map = $this->getTaxMap();
|
||||
$mock->total_tax_map = $this->getTotalTaxMap();
|
||||
$mock->invitation = InvoiceInvitation::factory()->make();
|
||||
$mock->invitation->company = Company::factory()->make();
|
||||
$mock->invitation->company->account = Account::factory()->make();
|
||||
|
||||
nlog($mock);
|
||||
return $mock;
|
||||
|
||||
}
|
||||
|
||||
private function getTaxMap()
|
||||
{
|
||||
|
||||
return collect( ['name' => 'GST', 'total' => 10]);
|
||||
|
||||
}
|
||||
|
||||
private function getTotalTaxMap()
|
||||
{
|
||||
return [['name' => 'GST', 'total' => 10]];
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,11 @@
|
||||
namespace Tests\Pdf;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\Country;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Currency;
|
||||
use Tests\MockAccountData;
|
||||
use App\Services\Pdf\PdfMock;
|
||||
use Beganovich\Snappdf\Snappdf;
|
||||
use App\Services\Pdf\PdfService;
|
||||
use App\Services\Pdf\PdfConfiguration;
|
||||
@ -40,5 +43,36 @@ class PdfmockTest extends TestCase
|
||||
$this->assertInstanceOf(Invoice::class, $entity);
|
||||
$this->assertNotNull($entity->client);
|
||||
|
||||
|
||||
$pdf_service = new PdfService($entity->invitation);
|
||||
|
||||
$this->assertNotNull($pdf_service);
|
||||
|
||||
$pdf_config = (new PdfConfiguration($pdf_service));
|
||||
|
||||
$this->assertNotNull($pdf_config);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testHtmlGeneration()
|
||||
{
|
||||
$mock = (new PdfMock())->build();
|
||||
|
||||
$pdf_service = new PdfService($mock->invitation);
|
||||
|
||||
$pdf_config = (new PdfConfiguration($pdf_service));
|
||||
$pdf_config->entity = $mock;
|
||||
$pdf_config->setTaxMap($mock->tax_map);
|
||||
$pdf_config->setTotalTaxMap($mock->total_tax_map);
|
||||
$pdf_config->setCurrency(Currency::find(1));
|
||||
$pdf_config->setCountry(Country::find(840));
|
||||
$pdf_config->client = $mock->client;
|
||||
$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;
|
||||
|
||||
$this->assertNotNull($pdf_config);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user