forked from easybill/zugferd-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilderReaderTest.php
More file actions
48 lines (35 loc) · 1.17 KB
/
BuilderReaderTest.php
File metadata and controls
48 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Easybill\ZUGFeRD\Tests;
use Doctrine\Common\Annotations\AnnotationRegistry;
use DOMDocument;
use Easybill\ZUGFeRD\Builder;
use Easybill\ZUGFeRD\ModelV2\Invoice;
use Easybill\ZUGFeRD\Reader;
use Easybill\ZUGFeRD\SchemaValidator;
use PHPUnit\Framework\TestCase;
class BuilderReaderTest extends TestCase
{
/**
* @before
*/
public function setupAnnotationRegistry(): void
{
AnnotationRegistry::registerLoader('class_exists');
}
public function testGetDocument(): void
{
$reader = Reader::create();
$doc = $reader->getDocument(file_get_contents(__DIR__ . '/zugferd-invoice.xml'),'zugferd.de.2p0');
$this->assertInstanceOf(Invoice::class, $doc);
$xml = Builder::create()->getXMLv2($doc);
$this->assertTrue(SchemaValidator::isValid($xml,'zugferd.de.2p0'));
$expected = new DOMDocument;
$expected_xml = file_get_contents(__DIR__ . '/zugferd-invoice.xml');
$expected->loadXML($expected_xml);
$actual = new DOMDocument;
$actual->loadXML($xml);
$this->assertEqualXMLStructure(
$expected->firstChild, $actual->firstChild
);
}
}