-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement undefined method in Encoding class (#378)
* Implement undefined method in Encoding class. The __toString method was missing/not implemented, even though it is called in some cases. Fixes #364 * Add PHPDoc and fix type error * Fix style issues * added test in FontTest to proof fix is working; coding style nice up in Font.php * added EncodingTest with 2 tests for new method "getEncodingClass" Co-authored-by: Konrad Abicht <hi@inspirito.de>
- Loading branch information
1 parent
5d37464
commit a4bb6d2
Showing
4 changed files
with
137 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* @file This file is part of the PdfParser library. | ||
* | ||
* @author Konrad Abicht <k.abicht@gmail.com> | ||
* @date 2020-06-01 | ||
* | ||
* @author Sébastien MALOT <sebastien@malot.fr> | ||
* @date 2017-01-03 | ||
* | ||
* @license LGPLv3 | ||
* @url <https://github.com/smalot/pdfparser> | ||
* | ||
* PdfParser is a pdf library written in PHP, extraction oriented. | ||
* Copyright (C) 2017 - Sébastien MALOT <sebastien@malot.fr> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. | ||
* If not, see <http://www.pdfparser.org/sites/default/LICENSE.txt>. | ||
*/ | ||
|
||
namespace Tests\Smalot\PdfParser\Integration; | ||
|
||
use Exception; | ||
use Smalot\PdfParser\Document; | ||
use Smalot\PdfParser\Element; | ||
use Smalot\PdfParser\Encoding; | ||
use Smalot\PdfParser\Encoding\StandardEncoding; | ||
use Smalot\PdfParser\Header; | ||
use Tests\Smalot\PdfParser\TestCase; | ||
|
||
class EncodingTest extends TestCase | ||
{ | ||
public function testGetEncodingClass() | ||
{ | ||
$header = new Header(['BaseEncoding' => new Element('StandardEncoding')]); | ||
|
||
$encoding = new Encoding(new Document(), $header); | ||
$encoding->init(); | ||
|
||
$this->assertEquals('\\'.StandardEncoding::class, $encoding->__toString()); | ||
} | ||
|
||
/** | ||
* This tests checks behavior if given Encoding class doesn't exist. | ||
*/ | ||
public function testGetEncodingClassMissingClassException() | ||
{ | ||
$this->expectException(Exception::class); | ||
$this->expectExceptionMessage('Missing encoding data for: "invalid"'); | ||
|
||
$header = new Header(['BaseEncoding' => new Element('invalid')]); | ||
|
||
$encoding = new Encoding(new Document(), $header); | ||
$encoding->init(); | ||
|
||
$encoding->__toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters