diff --git a/src/Report/Xml/BuildInformation.php b/src/Report/Xml/BuildInformation.php index dba230123..c91e5989e 100644 --- a/src/Report/Xml/BuildInformation.php +++ b/src/Report/Xml/BuildInformation.php @@ -62,14 +62,14 @@ public function setGeneratorVersions(string $phpUnitVersion, string $coverageVer private function nodeByName(string $name): DOMElement { $node = $this->contextNode->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, $name, )->item(0); if ($node === null) { $node = $this->contextNode->appendChild( $this->contextNode->ownerDocument->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, $name, ), ); diff --git a/src/Report/Xml/Coverage.php b/src/Report/Xml/Coverage.php index 812672081..9462780be 100644 --- a/src/Report/Xml/Coverage.php +++ b/src/Report/Xml/Coverage.php @@ -30,7 +30,7 @@ public function finalize(array $tests): void { $writer = new XMLWriter; $writer->openMemory(); - $writer->startElementNs(null, $this->contextNode->nodeName, 'https://schema.phpunit.de/coverage/1.0'); + $writer->startElementNs(null, $this->contextNode->nodeName, Facade::XML_NAMESPACE); $writer->writeAttribute('nr', $this->line); foreach ($tests as $test) { diff --git a/src/Report/Xml/Facade.php b/src/Report/Xml/Facade.php index 30c35e269..85d5cd5cf 100644 --- a/src/Report/Xml/Facade.php +++ b/src/Report/Xml/Facade.php @@ -43,6 +43,7 @@ */ final class Facade { + public const string XML_NAMESPACE = 'https://schema.phpunit.de/coverage/1.0'; private string $target; private Project $project; private readonly string $phpUnitVersion; diff --git a/src/Report/Xml/File.php b/src/Report/Xml/File.php index 4a3fea008..0d1e73955 100644 --- a/src/Report/Xml/File.php +++ b/src/Report/Xml/File.php @@ -34,7 +34,7 @@ public function totals(): Totals if ($totalsContainer === null) { $totalsContainer = $this->contextNode->appendChild( $this->dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'totals', ), ); @@ -48,14 +48,14 @@ public function totals(): Totals public function lineCoverage(string $line): Coverage { $coverage = $this->contextNode->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'coverage', )->item(0); if ($coverage === null) { $coverage = $this->contextNode->appendChild( $this->dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'coverage', ), ); @@ -63,7 +63,7 @@ public function lineCoverage(string $line): Coverage $lineNode = $coverage->appendChild( $this->dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'line', ), ); diff --git a/src/Report/Xml/Node.php b/src/Report/Xml/Node.php index e41197a08..e1f62ebac 100644 --- a/src/Report/Xml/Node.php +++ b/src/Report/Xml/Node.php @@ -38,7 +38,7 @@ public function totals(): Totals if ($totalsContainer === null) { $totalsContainer = $this->contextNode()->appendChild( $this->dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'totals', ), ); @@ -52,7 +52,7 @@ public function totals(): Totals public function addDirectory(string $name): Directory { $dirNode = $this->dom()->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'directory', ); @@ -65,7 +65,7 @@ public function addDirectory(string $name): Directory public function addFile(string $name, string $href): File { $fileNode = $this->dom()->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'file', ); diff --git a/src/Report/Xml/Project.php b/src/Report/Xml/Project.php index 21b5a2ce1..4c2295c10 100644 --- a/src/Report/Xml/Project.php +++ b/src/Report/Xml/Project.php @@ -35,14 +35,14 @@ public function projectSourceDirectory(): string public function buildInformation(): BuildInformation { $buildNode = $this->dom()->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'build', )->item(0); if ($buildNode === null) { $buildNode = $this->dom()->documentElement->appendChild( $this->dom()->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'build', ), ); @@ -56,14 +56,14 @@ public function buildInformation(): BuildInformation public function tests(): Tests { $testsNode = $this->contextNode()->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'tests', )->item(0); if ($testsNode === null) { $testsNode = $this->contextNode()->appendChild( $this->dom()->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'tests', ), ); @@ -86,7 +86,7 @@ private function init(): void $this->setContextNode( $dom->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'project', )->item(0), ); diff --git a/src/Report/Xml/Report.php b/src/Report/Xml/Report.php index f39ab860c..34f882171 100644 --- a/src/Report/Xml/Report.php +++ b/src/Report/Xml/Report.php @@ -26,7 +26,7 @@ public function __construct(string $name) $dom->loadXML(''); $contextNode = $dom->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'file', )->item(0); @@ -44,7 +44,7 @@ public function functionObject(string $name): Method { $node = $this->contextNode()->appendChild( $this->dom()->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'function', ), ); @@ -67,14 +67,14 @@ public function traitObject(string $name): Unit public function source(): Source { $source = $this->contextNode()->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'source', )->item(0); if ($source === null) { $source = $this->contextNode()->appendChild( $this->dom()->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'source', ), ); @@ -95,7 +95,7 @@ private function unitObject(string $tagName, string $name): Unit { $node = $this->contextNode()->appendChild( $this->dom()->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, $tagName, ), ); diff --git a/src/Report/Xml/Tests.php b/src/Report/Xml/Tests.php index c9e9c48ef..1760fdfa5 100644 --- a/src/Report/Xml/Tests.php +++ b/src/Report/Xml/Tests.php @@ -34,7 +34,7 @@ public function addTest(string $test, array $result): void { $node = $this->contextNode->appendChild( $this->contextNode->ownerDocument->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'test', ), ); diff --git a/src/Report/Xml/Totals.php b/src/Report/Xml/Totals.php index 8e285a78e..28612f7aa 100644 --- a/src/Report/Xml/Totals.php +++ b/src/Report/Xml/Totals.php @@ -29,27 +29,27 @@ public function __construct(DOMElement $container) $dom = $container->ownerDocument; $this->linesNode = $dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'lines', ); $this->methodsNode = $dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'methods', ); $this->functionsNode = $dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'functions', ); $this->classesNode = $dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'classes', ); $this->traitsNode = $dom->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'traits', ); diff --git a/src/Report/Xml/Unit.php b/src/Report/Xml/Unit.php index a00f85d39..84e189fbf 100644 --- a/src/Report/Xml/Unit.php +++ b/src/Report/Xml/Unit.php @@ -41,14 +41,14 @@ public function setCrap(float $crap): void public function setNamespace(string $namespace): void { $node = $this->contextNode->getElementsByTagNameNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'namespace', )->item(0); if ($node === null) { $node = $this->contextNode->appendChild( $this->contextNode->ownerDocument->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'namespace', ), ); @@ -63,7 +63,7 @@ public function addMethod(string $name): Method { $node = $this->contextNode->appendChild( $this->contextNode->ownerDocument->createElementNS( - 'https://schema.phpunit.de/coverage/1.0', + Facade::XML_NAMESPACE, 'method', ), );