Passed
Push — master ( 5d3746...a4bb6d )
by Konrad
02:09
created

EncodingTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 26
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetEncodingClass() 0 8 1
A testGetEncodingClassMissingClassException() 0 11 1
1
<?php
2
3
/**
4
 * @file This file is part of the PdfParser library.
5
 *
6
 * @author  Konrad Abicht <[email protected]>
7
 * @date    2020-06-01
8
 *
9
 * @author  Sébastien MALOT <[email protected]>
10
 * @date    2017-01-03
11
 *
12
 * @license LGPLv3
13
 * @url     <https://github.com/smalot/pdfparser>
14
 *
15
 *  PdfParser is a pdf library written in PHP, extraction oriented.
16
 *  Copyright (C) 2017 - Sébastien MALOT <[email protected]>
17
 *
18
 *  This program is free software: you can redistribute it and/or modify
19
 *  it under the terms of the GNU Lesser General Public License as published by
20
 *  the Free Software Foundation, either version 3 of the License, or
21
 *  (at your option) any later version.
22
 *
23
 *  This program is distributed in the hope that it will be useful,
24
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 *  GNU Lesser General Public License for more details.
27
 *
28
 *  You should have received a copy of the GNU Lesser General Public License
29
 *  along with this program.
30
 *  If not, see <http://www.pdfparser.org/sites/default/LICENSE.txt>.
31
 */
32
33
namespace Tests\Smalot\PdfParser\Integration;
34
35
use Exception;
36
use Smalot\PdfParser\Document;
37
use Smalot\PdfParser\Element;
38
use Smalot\PdfParser\Encoding;
39
use Smalot\PdfParser\Encoding\StandardEncoding;
40
use Smalot\PdfParser\Header;
41
use Tests\Smalot\PdfParser\TestCase;
42
43
class EncodingTest extends TestCase
44
{
45
    public function testGetEncodingClass()
46
    {
47
        $header = new Header(['BaseEncoding' => new Element('StandardEncoding')]);
48
49
        $encoding = new Encoding(new Document(), $header);
50
        $encoding->init();
51
52
        $this->assertEquals('\\'.StandardEncoding::class, $encoding->__toString());
53
    }
54
55
    /**
56
     * This tests checks behavior if given Encoding class doesn't exist.
57
     */
58
    public function testGetEncodingClassMissingClassException()
59
    {
60
        $this->expectException(Exception::class);
61
        $this->expectExceptionMessage('Missing encoding data for: "invalid"');
62
63
        $header = new Header(['BaseEncoding' => new Element('invalid')]);
64
65
        $encoding = new Encoding(new Document(), $header);
66
        $encoding->init();
67
68
        $encoding->__toString();
69
    }
70
}
71