-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#120 ZugferdDocumentPdfReader now contains additional methods for ext…
…racting the XML content
- Loading branch information
HorstOeko
committed
Sep 24, 2024
1 parent
1422fc1
commit 10fc7d3
Showing
4 changed files
with
112 additions
and
26 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,52 @@ | ||
<?php | ||
|
||
namespace horstoeko\zugferd\tests\testcases; | ||
|
||
use horstoeko\zugferd\exception\ZugferdFileNotFoundException; | ||
use \horstoeko\zugferd\tests\TestCase; | ||
use horstoeko\zugferd\ZugferdDocument; | ||
use \horstoeko\zugferd\ZugferdDocumentPdfReader; | ||
|
||
class PdfReaderGeneralTest extends TestCase | ||
{ | ||
public function testCanReadPdf(): void | ||
{ | ||
$document = ZugferdDocumentPdfReader::readAndGuessFromFile(dirname(__FILE__) . "/../assets/InvalidPDF.pdf"); | ||
$this->assertNull($document); | ||
} | ||
|
||
public function testFileNotFound(): void | ||
{ | ||
$this->expectException(ZugferdFileNotFoundException::class); | ||
$document = ZugferdDocumentPdfReader::readAndGuessFromFile(dirname(__FILE__) . "/../assets/unknown.pdf"); | ||
} | ||
|
||
public function testCanReadPdf2(): void | ||
{ | ||
$document = ZugferdDocumentPdfReader::getXmlFromFile(dirname(__FILE__) . "/../assets/InvalidPDF.pdf"); | ||
$this->assertNull($document); | ||
} | ||
|
||
public function testFileNotFound2(): void | ||
{ | ||
$this->expectException(ZugferdFileNotFoundException::class); | ||
$document = ZugferdDocumentPdfReader::getXmlFromFile(dirname(__FILE__) . "/../assets/unknown.pdf"); | ||
} | ||
|
||
public function testCanReadPdf3(): void | ||
{ | ||
$document = ZugferdDocumentPdfReader::readAndGuessFromFile(dirname(__FILE__) . "/../assets/zugferd_2p1_EN16931_Einfach.pdf"); | ||
$this->assertNotNull($document); | ||
$this->assertInstanceOf(ZugferdDocument::class, $document); | ||
} | ||
|
||
public function testCanReadPdf4(): void | ||
{ | ||
$xmlString = ZugferdDocumentPdfReader::getXmlFromFile(dirname(__FILE__) . "/../assets/zugferd_2p1_EN16931_Einfach.pdf"); | ||
$this->assertNotNull($xmlString); | ||
$this->assertIsString($xmlString); | ||
$this->assertStringContainsString("<?xml version='1.0'", $xmlString); | ||
$this->assertStringContainsString("<rsm:CrossIndustryInvoice", $xmlString); | ||
$this->assertStringContainsString("</rsm:CrossIndustryInvoice>", $xmlString); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.