1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/tests/Pdf/PdfGenerationTest.php

140 lines
3.3 KiB
PHP
Raw Normal View History

2019-05-04 05:14:37 +02:00
<?php
namespace Tests\Pdf;
2019-05-04 05:17:44 +02:00
use Illuminate\Support\Facades\Storage;
2019-05-04 05:14:37 +02:00
use Spatie\Browsershot\Browsershot;
use Tests\TestCase;
/**
* @test
//@covers App\DataMapper\BaseSettings
*/
class PdfGenerationTest extends TestCase
{
public function setUp() :void
{
parent::setUp();
}
private function makePdf($header, $footer, $html, $pdf)
{
Browsershot::html($html)
//->showBrowserHeaderAndFooter()
//->headerHtml($header)
//->footerHtml($footer)
->waitUntilNetworkIdle()
//->margins(10,10,10,10)
->savePdf($pdf);
}
public function testPdfGeneration()
{
$html = file_get_contents(base_path().'/tests/Pdf/invoice.html');
$pdf = base_path().'/tests/Pdf/invoice.pdf';
$header = '<div style="font-size:14px;"<header></header>';
$footer = ' <div style="font-size:14px;"><footer>
2019-05-04 08:55:19 +02:00
<span class="pageNumber"></span> / <span class="totalPages"></span>
</footer></div>';
$this->makePdf($header, $footer, $html, $pdf);
2019-05-04 08:55:19 +02:00
$this->assertTrue(file_exists($pdf));
2019-05-04 08:55:19 +02:00
unlink($pdf);
}
2019-05-04 08:55:19 +02:00
public function testPdfGeneration2()
{
$html = file_get_contents(base_path().'/tests/Pdf/invoice2.html');
$pdf = base_path().'/tests/Pdf/invoice2.pdf';
2019-05-04 08:55:19 +02:00
$header = '<div style="font-size:14px;"<header></header>';
2019-05-04 08:55:19 +02:00
$footer = ' <div style="font-size:14px;"><footer>
2019-05-04 08:55:19 +02:00
<span class="pageNumber"></span> / <span class="totalPages"></span>
</footer></div>';
$this->makePdf($header, $footer, $html, $pdf);
2019-05-04 08:55:19 +02:00
2019-05-04 05:14:37 +02:00
$this->assertTrue(file_exists($pdf));
2019-05-04 05:14:37 +02:00
2019-05-04 08:55:19 +02:00
unlink($pdf);
}
2019-05-04 08:55:19 +02:00
public function testPdfGeneration3()
{
$html = file_get_contents(base_path().'/tests/Pdf/invoice3.html');
$pdf = base_path().'/tests/Pdf/invoice3.pdf';
2019-05-04 08:55:19 +02:00
$header = '<div style="font-size:14px;"<header></header>';
2019-05-04 08:55:19 +02:00
$footer = ' <div style="font-size:14px;"><footer>
2019-05-04 08:55:19 +02:00
<span class="pageNumber"></span> / <span class="totalPages"></span>
</footer></div>';
$this->makePdf($header, $footer, $html, $pdf);
2019-05-04 08:55:19 +02:00
$this->assertTrue(file_exists($pdf));
2019-05-04 08:55:19 +02:00
unlink($pdf);
}
2019-05-04 08:55:19 +02:00
public function testPdfGeneration4()
{
$html = file_get_contents(base_path().'/tests/Pdf/invoice4.html');
$pdf = base_path().'/tests/Pdf/invoice4.pdf';
2019-05-04 08:55:19 +02:00
$header = '<div style="font-size:14px;"<header></header>';
2019-05-04 08:55:19 +02:00
$footer = ' <div style="font-size:14px;"><footer>
2019-05-04 08:55:19 +02:00
<span class="pageNumber"></span> / <span class="totalPages"></span>
</footer></div>';
$this->makePdf($header, $footer, $html, $pdf);
2019-05-04 08:55:19 +02:00
$this->assertTrue(file_exists($pdf));
2019-05-04 08:55:19 +02:00
unlink($pdf);
}
2019-05-04 08:55:19 +02:00
public function testPdfGeneration5()
{
$html = file_get_contents(base_path().'/tests/Pdf/invoice5.html');
$pdf = base_path().'/tests/Pdf/invoice5.pdf';
2019-05-04 08:55:19 +02:00
$header = '<div style="font-size:14px;"<header></header>';
2019-05-04 08:55:19 +02:00
$footer = ' <div style="font-size:14px;"><footer>
2019-05-04 08:55:19 +02:00
<span class="pageNumber"></span> / <span class="totalPages"></span>
</footer></div>';
$this->makePdf($header, $footer, $html, $pdf);
2019-05-04 08:55:19 +02:00
$this->assertTrue(file_exists($pdf));
2019-05-04 08:55:19 +02:00
2019-05-04 05:17:44 +02:00
unlink($pdf);
}
2019-05-04 05:14:37 +02:00
}