feat: convert uploaded contracts and invoices to pdf
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user