Skip to content

Commit

Permalink
Merge pull request #14 from albertodimaio3/improve-attribute-checks
Browse files Browse the repository at this point in the history
Check that attributes exist before adding them to the count
  • Loading branch information
andreaskweber committed Jul 19, 2021
2 parents 75bc713 + a983509 commit 6ad3965
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ private function mergeFiles($directory, Finder $finder, $noSuffix)
}
$outTestSuite->appendChild($outElement);

$tests += $inElement->getAttribute('tests');
$assertions += $inElement->getAttribute('assertions');
$failures += $inElement->getAttribute('failures');
$errors += $inElement->getAttribute('errors');
$time += $inElement->getAttribute('time');
$tests += $inElement->hasAttribute('tests') ? $inElement->getAttribute('tests') : 0;
$assertions += $inElement->hasAttribute('assertions') ? $inElement->getAttribute('assertions') : 0;
$failures += $inElement->hasAttribute('failures') ? $inElement->getAttribute('failures') : 0;
$errors += $inElement->hasAttribute('errors') ? $inElement->getAttribute('errors') : 0;
$time += $inElement->hasAttribute('time') ? $inElement->getAttribute('time') : 0;
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/Test/Unit/Fixtures/normal/phpcs-junit-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="PHP_CodeSniffer 3.5.5" errors="0" tests="2" failures="0">
<testsuite name="Unit/Testsuite1.php" errors="0" tests="1" failures="0">
<testcase name="Unit/Testsuite1.php" />
</testsuite>
<testsuite name="Unit/Testsuite2.php" errors="0" tests="1" failures="0">
<testcase name="Unit/Testsuite2.php" />
</testsuite>
</testsuites>

0 comments on commit 6ad3965

Please sign in to comment.