Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Report/Xml/BuildInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
);
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Xml/Coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/Report/Xml/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/Report/Xml/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
);
Expand All @@ -48,22 +48,22 @@ 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',
),
);
}

$lineNode = $coverage->appendChild(
$this->dom->createElementNS(
'https://schema.phpunit.de/coverage/1.0',
Facade::XML_NAMESPACE,
'line',
),
);
Expand Down
6 changes: 3 additions & 3 deletions src/Report/Xml/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
);
Expand All @@ -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',
);

Expand All @@ -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',
);

Expand Down
10 changes: 5 additions & 5 deletions src/Report/Xml/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
);
Expand All @@ -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',
),
);
Expand All @@ -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),
);
Expand Down
10 changes: 5 additions & 5 deletions src/Report/Xml/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(string $name)
$dom->loadXML('<?xml version="1.0" ?><phpunit xmlns="https://schema.phpunit.de/coverage/1.0"><file /></phpunit>');

$contextNode = $dom->getElementsByTagNameNS(
'https://schema.phpunit.de/coverage/1.0',
Facade::XML_NAMESPACE,
'file',
)->item(0);

Expand All @@ -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',
),
);
Expand All @@ -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',
),
);
Expand All @@ -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,
),
);
Expand Down
2 changes: 1 addition & 1 deletion src/Report/Xml/Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
);
Expand Down
10 changes: 5 additions & 5 deletions src/Report/Xml/Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);

Expand Down
6 changes: 3 additions & 3 deletions src/Report/Xml/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
);
Expand All @@ -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',
),
);
Expand Down