feat: convert uploaded contracts and invoices to pdf

This commit is contained in:
Björn Fromme
2025-03-04 14:13:09 +01:00
parent ab6d350045
commit 917640183f
9 changed files with 164 additions and 8 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Tests\Service\Pdf;
use App\Service\Pdf\Sanitizer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
class SanitizerTest extends TestCase
{
public function testAcceptsImages(): void
{
$tempDir = realpath(__DIR__.'/../../../temp');
$sourceFilepath = realpath(__DIR__.'/../../Resources/upload.jpg');
$targetFilepath = $tempDir.'/test.pdf';
$sanitizer = new Sanitizer('/usr/bin/gs', '/usr/bin/convert', $tempDir);
$sanitizer->sanitizeFile($sourceFilepath, $targetFilepath);
$this->assertFileExists($targetFilepath);
(new Filesystem())->remove($targetFilepath);
}
public function testAcceptsPdfs(): void
{
$tempDir = realpath(__DIR__.'/../../../temp');
$sourceFilepath = realpath(__DIR__.'/../../Resources/upload.pdf');
$targetFilepath = $tempDir.'/test.pdf';
$sanitizer = new Sanitizer('/usr/bin/gs', '/usr/bin/convert', $tempDir);
$sanitizer->sanitizeFile($sourceFilepath, $targetFilepath);
$this->assertFileExists($targetFilepath);
(new Filesystem())->remove($targetFilepath);
}
}