File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 44
55namespace SimpleSAML \Test \XML ;
66
7+ use DOMDocument ;
78use PHPUnit \Framework \Attributes \CoversClass ;
89use PHPUnit \Framework \Attributes \Group ;
910use PHPUnit \Framework \TestCase ;
1011use RuntimeException ;
1112use SimpleSAML \Assert \AssertionFailedException ;
1213use SimpleSAML \XML \DOMDocumentFactory ;
14+ use SimpleSAML \XML \Exception \SchemaViolationException ;
1315use SimpleSAML \XML \Exception \UnparseableXMLException ;
1416
1517use function strval ;
@@ -114,4 +116,23 @@ public function testEmptyStringIsNotValid(): void
114116 );
115117 DOMDocumentFactory::fromString ('' );
116118 }
119+
120+
121+ public function testSchemaValidationPasses (): void
122+ {
123+ $ file = 'tests/resources/xml/ssp_Chunk.xml ' ;
124+ $ schemaFile = 'tests/resources/schemas/simplesamlphp.xsd ' ;
125+ $ doc = DOMDocumentFactory::fromFile ($ file , $ schemaFile );
126+ $ this ->assertInstanceOf (DOMDocument::class, $ doc );
127+ }
128+
129+
130+ public function testSchemaValidationWrongElementFails (): void
131+ {
132+ $ file = 'tests/resources/xml/ssp_BooleanElement.xml ' ;
133+ $ schemaFile = 'tests/resources/schemas/simplesamlphp.xsd ' ;
134+
135+ $ this ->expectException (SchemaViolationException::class);
136+ DOMDocumentFactory::fromFile ($ file , $ schemaFile );
137+ }
117138}
Original file line number Diff line number Diff line change 1+ <ssp : Chunk xmlns : ssp =" urn:x-simplesamlphp:namespace" >Some</ssp : Chunk >
You can’t perform that action at this time.
0 commit comments