1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/tests/Pdf/PdfServiceTest.php

111 lines
2.3 KiB
PHP
Raw Normal View History

2022-12-23 03:22:01 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Pdf;
use App\Services\Pdf\PdfConfiguration;
use App\Services\Pdf\PdfService;
use Beganovich\Snappdf\Snappdf;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers App\Services\Pdf\PdfService
*/
class PdfServiceTest extends TestCase
{
use MockAccountData;
protected function setUp(): void
{
parent::setUp();
$this->makeTestData();
}
2022-12-28 15:50:11 +01:00
public function testPdfGeneration()
2022-12-28 11:28:58 +01:00
{
$invitation = $this->invoice->invitations->first();
2023-02-28 08:05:08 +01:00
$service = (new PdfService($invitation))->boot();
2022-12-28 11:28:58 +01:00
2022-12-28 15:50:11 +01:00
$this->assertNotNull($service->getPdf());
}
public function testHtmlGeneration()
{
$invitation = $this->invoice->invitations->first();
2023-02-28 08:05:08 +01:00
$service = (new PdfService($invitation))->boot();
2022-12-28 11:28:58 +01:00
2022-12-28 15:50:11 +01:00
$this->assertIsString($service->getHtml());
2022-12-28 11:28:58 +01:00
}
2022-12-23 03:22:01 +01:00
public function testInitOfClass()
{
$invitation = $this->invoice->invitations->first();
2023-02-28 08:05:08 +01:00
$service = (new PdfService($invitation))->boot();
2022-12-23 03:22:01 +01:00
$this->assertInstanceOf(PdfService::class, $service);
}
public function testEntityResolution()
{
$invitation = $this->invoice->invitations->first();
2023-02-28 08:05:08 +01:00
$service = (new PdfService($invitation))->boot();
2022-12-23 03:22:01 +01:00
$this->assertInstanceOf(PdfConfiguration::class, $service->config);
}
public function testDefaultDesign()
{
$invitation = $this->invoice->invitations->first();
2023-02-28 08:05:08 +01:00
$service = (new PdfService($invitation))->boot();
2022-12-23 03:22:01 +01:00
$this->assertEquals(2, $service->config->design->id);
}
2022-12-23 03:46:52 +01:00
public function testHtmlIsArray()
{
$invitation = $this->invoice->invitations->first();
2023-02-28 08:05:08 +01:00
$service = (new PdfService($invitation))->boot();
2022-12-23 03:46:52 +01:00
$this->assertIsArray($service->html_variables);
}
public function testTemplateResolution()
{
$invitation = $this->invoice->invitations->first();
2023-02-28 08:05:08 +01:00
$service = (new PdfService($invitation))->boot();
2022-12-23 03:46:52 +01:00
$this->assertIsString($service->designer->template);
}
2022-12-28 11:28:58 +01:00
2022-12-23 03:22:01 +01:00
}