Test Failed
Pull Request — master (#653)
by Konrad
02:03
created

EncryptionTest::testNoIgnoreEncryption()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
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);
0 ignored issues
show
Unused Code introduced by
The assignment to $document is dead and can be removed.
Loading history...
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);
0 ignored issues
show
Deprecated Code introduced by
The function Smalot\PdfParser\Config::setIgnoreEncryption() has been deprecated: this is a temporary workaround, don't rely on it ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

57
        /** @scrutinizer ignore-deprecated */ $config->setIgnoreEncryption(true);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
58
        $parser = new Parser([], $config);
59
60
        $filename = $this->rootDir.'/samples/not_really_encrypted.pdf';
61
        $document = $parser->parseFile($filename);
0 ignored issues
show
Unused Code introduced by
The assignment to $document is dead and can be removed.
Loading history...
62
        $this->assertTrue(true);
63
    }
64
}
65