1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace Royopa\AlphaPDF\Tests; |
||
5 | |||
6 | use Symfony\Component\Security\Core\User\User; |
||
7 | use PHPUnit\Framework\TestCase; |
||
8 | use Royopa\AlphaPDF\AlphaPDF; |
||
9 | use Royopa\AlphaPDF\WaterMark; |
||
10 | use Royopa\AlphaPDF\Fpdi; |
||
11 | use Symfony\Component\Filesystem\Filesystem; |
||
12 | |||
13 | class AlphaPDFTest extends TestCase |
||
14 | { |
||
15 | protected $user; |
||
16 | protected $sourceFile; |
||
17 | protected $outputFile; |
||
18 | |||
19 | public function testIsInstanceOfFpdi() |
||
20 | { |
||
21 | $alphaPdf = new AlphaPDF(); |
||
22 | $isInstance = false; |
||
23 | if ($alphaPdf instanceof \setasign\Fpdi\Fpdi) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
24 | $isInstance = true; |
||
25 | } |
||
26 | $this->assertTrue($isInstance); |
||
27 | |||
28 | if ($alphaPdf instanceof \Royopa\AlphaPDF\Fpdi) { |
||
0 ignored issues
–
show
|
|||
29 | $isInstance = true; |
||
30 | } |
||
31 | $this->assertTrue($isInstance); |
||
32 | } |
||
33 | |||
34 | public function testNumPagesWaterMark() |
||
35 | { |
||
36 | $waterMark = new WaterMark($this->sourceFile, $this->user); |
||
37 | $this->assertEquals( |
||
38 | 20, |
||
39 | $waterMark->getPdf()->getNumPages() |
||
40 | ); |
||
41 | } |
||
42 | |||
43 | public function testUserWaterMark() |
||
44 | { |
||
45 | $waterMark = new WaterMark($this->sourceFile, $this->user); |
||
46 | |||
47 | $waterMark |
||
48 | ->doWaterMark() |
||
49 | ->Output('F', $this->outputFile) |
||
50 | ; |
||
51 | |||
52 | $waterMarkOutput = new WaterMark($this->outputFile, $this->user); |
||
53 | |||
54 | $this->assertEquals( |
||
55 | $waterMark->getPdf()->getNumPages(), |
||
56 | $waterMarkOutput->getPdf()->getNumPages() |
||
57 | ); |
||
58 | } |
||
59 | |||
60 | public function setUp() |
||
61 | { |
||
62 | $this->user = new User('royopa', '123456'); |
||
63 | $this->sourceFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CVM-Guia-01-FII.pdf'; |
||
64 | $this->outputFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CVM-Guia-01-FII.output.pdf'; |
||
65 | } |
||
66 | |||
67 | public function tearDown() |
||
68 | { |
||
69 | $fs = new Filesystem(); |
||
70 | $fs->remove($this->outputFile); |
||
71 | } |
||
72 | } |