1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file This file is part of the PdfParser library. |
5
|
|
|
* |
6
|
|
|
* @author Alastair Irvine <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @date 2023-11-22 |
9
|
|
|
* |
10
|
|
|
* @license LGPLv3 |
11
|
|
|
* |
12
|
|
|
* @url <https://github.com/smalot/pdfparser> |
13
|
|
|
* |
14
|
|
|
* PdfParser is a pdf library written in PHP, extraction oriented. |
15
|
|
|
* Copyright (C) 2017 - Sébastien MALOT <[email protected]> |
16
|
|
|
* |
17
|
|
|
* This program is free software: you can redistribute it and/or modify |
18
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
19
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
20
|
|
|
* (at your option) any later version. |
21
|
|
|
* |
22
|
|
|
* This program is distributed in the hope that it will be useful, |
23
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
24
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25
|
|
|
* GNU Lesser General Public License for more details. |
26
|
|
|
* |
27
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
28
|
|
|
* along with this program. |
29
|
|
|
* If not, see <http://www.pdfparser.org/sites/default/LICENSE.txt>. |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
namespace PHPUnitTests\Integration; |
33
|
|
|
|
34
|
|
|
use PHPUnitTests\TestCase; |
35
|
|
|
use Smalot\PdfParser\Config; |
36
|
|
|
use Smalot\PdfParser\Parser; |
37
|
|
|
|
38
|
|
|
class EncryptionTest extends TestCase |
39
|
|
|
{ |
40
|
|
|
public function testNoIgnoreEncryption(): void |
41
|
|
|
{ |
42
|
|
|
$parser = new Parser(); |
43
|
|
|
|
44
|
|
|
$filename = $this->rootDir.'/samples/not_really_encrypted.pdf'; |
45
|
|
|
$threw = false; |
46
|
|
|
try { |
47
|
|
|
$document = $parser->parseFile($filename); |
|
|
|
|
48
|
|
|
} catch (\Exception $e) { |
49
|
|
|
$threw = true; |
50
|
|
|
} |
51
|
|
|
$this->assertTrue($threw); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testIgnoreEncryption(): void |
55
|
|
|
{ |
56
|
|
|
$config = new Config(); |
57
|
|
|
$config->setIgnoreEncryption(true); |
|
|
|
|
58
|
|
|
$parser = new Parser([], $config); |
59
|
|
|
|
60
|
|
|
$filename = $this->rootDir.'/samples/not_really_encrypted.pdf'; |
61
|
|
|
$document = $parser->parseFile($filename); |
|
|
|
|
62
|
|
|
$this->assertTrue(true); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|