Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSD schema based XML validation in PHP unit test

I am developing a PHP-powered application component which exports some data to an XML file which must follow a scheme defined by XSD file. I know how to validate the file manually, but it would be very handy if this could be done within unit tests.

Is there any library or framework available which can me help doing that?

like image 510
miho Avatar asked Oct 19 '22 18:10

miho


1 Answers

One possibility would be to use DOMDocument::schemaValidate or DOMDocument::schemaValidateSource. Since either of those two methods returns a boolean value, you could then assert that the returned value is true.

like image 148
Havelock Avatar answered Nov 18 '22 01:11

Havelock