lastdragon-ru/phpunit-xml
Tools for working with PHPUnit’s XML configuration: parse, build, and validate phpunit.xml files programmatically. Useful for CI automation, config generation, and upgrades/migrations between PHPUnit versions, with a focused API designed for PHP projects.
lastdragon-ru/phpunit-xml package extends PHPUnit’s assertion capabilities to validate XML structures, schemas, and content. This is a niche but valuable addition for projects requiring rigorous XML validation (e.g., SOAP APIs, config files, legacy integrations, or compliance-driven systems).config/app.xml or custom formats).assertXmlFileEqualsXmlFile, assertXmlStringEqualsXmlString) or libraries like SimpleXMLElement may suffice for basic cases, but this package offers dedicated XML schema validation (e.g., XSD compliance) and fluent assertions, reducing boilerplate.Guzzle + php-soap).config() or file_get_contents().php artisan validate:xml config/app.xml).xmllint CLI) for pre-validation.DOMDocument, SimpleXML) that could achieve 80% of the goal with less risk?laravel-xml-assertions) be built?tests/Feature/SoapApiTest.php).tests/Unit/ConfigXmlTest.php).php artisan validate:xml) to check XML files during deployment.SimpleXML, DOMDocument, or XMLReader instead).composer require lastdragon-ru/phpunit-xml --dev
assertXmlSchemaValid).use LastDragon\PHPUnitXml\Assert;
trait SoapXmlAssertions {
public function assertSoapResponseValid(string $xml, string $schemaPath) {
Assert::xmlSchemaValid($xml, $schemaPath);
}
}
TESTING.md section.composer.json constraints).libxml).mb_* functions for other encodings.composer.json and test in a single test file.libxml config, file permissions).composer.json to avoid breaking changes.--debug flag for assertion traces.SimpleXML for critical cases.SchemaFactory pattern).@group xml in PHPUnit to run validations in parallel.tests/_data/xml/schemas/ and load via file_get_contents().composer.json or package.json.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Package breaks with PHPUnit update | Tests fail; no production impact. | Pin PHPUnit version; fork if critical. |
| XML schema validation fails | False negatives in API tests. | Review schema definitions; use xmllint for pre-validation. |
| Large XML files cause timeouts | CI/CD pipeline failures. | Stream validation; increase memory limits. |
| Environment-specific XML parsing | Tests pass locally but fail in CI. | Containerize test environments (Docker). |
How can I help you explore Laravel packages today?