Skip to content

Commit 0df7970

Browse files
committed
Add better document test for error handling switches
1 parent 8ed6a30 commit 0df7970

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/document/DocumentTest.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPUnit\Framework\TestCase;
2222
use Templado\Engine\Example\ViewModel;
2323
use Throwable;
24+
use function libxml_use_internal_errors;
2425

2526
#[CoversClass(Document::class)]
2627
#[UsesClass(Id::class)]
@@ -50,6 +51,14 @@ public function testCanBeConstructedFromString(): void {
5051
);
5152
}
5253

54+
public function testUsageEnablesLibxmlInternalErrorHandler(): void {
55+
libxml_use_internal_errors(false);
56+
57+
Document::fromString('<?xml version="1.0" ?><root />');
58+
59+
$this->assertTrue(libxml_use_internal_errors());
60+
}
61+
5362
public function testCanBeConstructFromDomDocument(): void {
5463
$dom = new DOMDocument();
5564
$dom->loadXML('<?xml version="1.0" ?><root />');
@@ -93,7 +102,6 @@ public function testExistingLibxmlErrorStateGetsClearedOnConstruct(): void {
93102
libxml_use_internal_errors(true);
94103
$dummy = new DOMDocument();
95104
$dummy->loadXML('parsing-this-will-cause-libxml-errors');
96-
libxml_use_internal_errors(false);
97105

98106
$this->assertInstanceOf(
99107
Document::class,

0 commit comments

Comments
 (0)