assertEquals( $this->normalizeXml($expectedXml), $this->normalizeXml($actualXml) ); } protected function normalizeXml(string $xml): string { $doc = new \DOMDocument('1.0'); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; if (!$doc->loadXML($xml)) { throw new \DOMException('Failed to load XML in normalizeXml'); } return $doc->saveXML(); } protected function assertValidatesAgainstXsd(string $xml, string $xsdPath): void { try { $doc = new \DOMDocument(); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; if (!$doc->loadXML($xml, LIBXML_NOBLANKS)) { throw new \DOMException('Failed to load XML in assertValidatesAgainstXsd'); } libxml_use_internal_errors(true); $result = $doc->schemaValidate($xsdPath); if (!$result) { foreach (libxml_get_errors() as $error) { } libxml_clear_errors(); } $this->assertTrue( $result, 'XML does not validate against XSD schema' ); } catch (\Exception $e) { throw $e; } } protected function getTestXsdPath(): string { return __DIR__ . '/../schema/SuministroInformacion.xsd'; } }