Skip to content

Commit 7d7dc3d

Browse files
committed
Slightly raise coverage
1 parent 994de22 commit 7d7dc3d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/XML/DOMDocumentFactoryTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SimpleSAML\Test\XML;
66

77
use DOMDocument;
8+
use Exception;
89
use PHPUnit\Framework\Attributes\CoversClass;
910
use PHPUnit\Framework\Attributes\Group;
1011
use PHPUnit\Framework\TestCase;
@@ -14,6 +15,8 @@
1415
use SimpleSAML\XML\Exception\SchemaViolationException;
1516
use SimpleSAML\XML\Exception\UnparseableXMLException;
1617

18+
use function restore_error_handler;
19+
use function set_error_handler;
1720
use function strval;
1821

1922
/**
@@ -135,4 +138,20 @@ public function testSchemaValidationWrongElementFails(): void
135138
$this->expectException(SchemaViolationException::class);
136139
DOMDocumentFactory::fromFile($file, $schemaFile);
137140
}
141+
142+
143+
public function testSchemaValidationUnknownSchemaFileFails(): void
144+
{
145+
$file = 'tests/resources/xml/ssp_Chunk.xml';
146+
$schemaFile = 'tests/resources/schemas/doesnotexist.xsd';
147+
148+
// Dirty trick to catch the warning emitted by PHP
149+
set_error_handler(static function (int $errno, string $errstr): never {
150+
restore_error_handler();
151+
throw new Exception($errstr, $errno);
152+
}, E_WARNING);
153+
154+
$this->expectExceptionMessage('Failed to locate the main schema resource at');
155+
DOMDocumentFactory::fromFile($file, $schemaFile);
156+
}
138157
}

0 commit comments

Comments
 (0)