Skip to content

Commit 6ad3965

Browse files
Merge pull request #14 from albertodimaio3/improve-attribute-checks
Check that attributes exist before adding them to the count
2 parents 75bc713 + a983509 commit 6ad3965

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/Console/Command.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ private function mergeFiles($directory, Finder $finder, $noSuffix)
214214
}
215215
$outTestSuite->appendChild($outElement);
216216

217-
$tests += $inElement->getAttribute('tests');
218-
$assertions += $inElement->getAttribute('assertions');
219-
$failures += $inElement->getAttribute('failures');
220-
$errors += $inElement->getAttribute('errors');
221-
$time += $inElement->getAttribute('time');
217+
$tests += $inElement->hasAttribute('tests') ? $inElement->getAttribute('tests') : 0;
218+
$assertions += $inElement->hasAttribute('assertions') ? $inElement->getAttribute('assertions') : 0;
219+
$failures += $inElement->hasAttribute('failures') ? $inElement->getAttribute('failures') : 0;
220+
$errors += $inElement->hasAttribute('errors') ? $inElement->getAttribute('errors') : 0;
221+
$time += $inElement->hasAttribute('time') ? $inElement->getAttribute('time') : 0;
222222
}
223223
}
224224

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="PHP_CodeSniffer 3.5.5" errors="0" tests="2" failures="0">
3+
<testsuite name="Unit/Testsuite1.php" errors="0" tests="1" failures="0">
4+
<testcase name="Unit/Testsuite1.php" />
5+
</testsuite>
6+
<testsuite name="Unit/Testsuite2.php" errors="0" tests="1" failures="0">
7+
<testcase name="Unit/Testsuite2.php" />
8+
</testsuite>
9+
</testsuites>

0 commit comments

Comments
 (0)