File tree 1 file changed +19
-0
lines changed 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 5
5
namespace SimpleSAML \Test \XML ;
6
6
7
7
use DOMDocument ;
8
+ use Exception ;
8
9
use PHPUnit \Framework \Attributes \CoversClass ;
9
10
use PHPUnit \Framework \Attributes \Group ;
10
11
use PHPUnit \Framework \TestCase ;
14
15
use SimpleSAML \XML \Exception \SchemaViolationException ;
15
16
use SimpleSAML \XML \Exception \UnparseableXMLException ;
16
17
18
+ use function restore_error_handler ;
19
+ use function set_error_handler ;
17
20
use function strval ;
18
21
19
22
/**
@@ -135,4 +138,20 @@ public function testSchemaValidationWrongElementFails(): void
135
138
$ this ->expectException (SchemaViolationException::class);
136
139
DOMDocumentFactory::fromFile ($ file , $ schemaFile );
137
140
}
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
+ }
138
157
}
You can’t perform that action at this time.
0 commit comments