Skip to content

Commit

Permalink
Add PdfMerger unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomsgu committed Apr 6, 2022
1 parent 18f8007 commit 79e1b0a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/Unit/PdfMergerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace Tomsgu\PdfMerger\Test\Unit;

use PHPUnit\Framework\TestCase;
use setasign\Fpdi\Fpdi;
use Tomsgu\PdfMerger\Exception\InvalidArgumentException;
use Tomsgu\PdfMerger\PdfCollection;
use Tomsgu\PdfMerger\PdfMerger;

/**
* @author Tomas Jakl <[email protected]>
*/
class PdfMergerTest extends TestCase
{
const TEST_FILE = './tests/Data/landscape.pdf';

public function testEmptyCollection()
{
$collection = new PdfCollection();
$fpdi = new Fpdi();
$merger = new PdfMerger($fpdi);

$this->expectException(InvalidArgumentException::class);
$merger->merge($collection, 'new_file.pdf', PdfMerger::MODE_FILE);
}

public function testInvalidMode()
{
$collection = new PdfCollection();
$collection->addPdf(self::TEST_FILE);
$fpdi = new Fpdi();
$merger = new PdfMerger($fpdi);

$this->expectException(InvalidArgumentException::class);
$merger->merge($collection, 'new_file.pdf', 'ZZZ');
}
}

0 comments on commit 79e1b0a

Please sign in to comment.