File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 55namespace SimpleSAML \Test \XML ;
66
77use DOMDocument ;
8+ use Exception ;
89use PHPUnit \Framework \Attributes \CoversClass ;
910use PHPUnit \Framework \Attributes \Group ;
1011use PHPUnit \Framework \TestCase ;
1415use SimpleSAML \XML \Exception \SchemaViolationException ;
1516use SimpleSAML \XML \Exception \UnparseableXMLException ;
1617
18+ use function restore_error_handler ;
19+ use function set_error_handler ;
1720use 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}
You can’t perform that action at this time.
0 commit comments