Total |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
75.00% covered (warning)
@@ -72,13 +72,13 @@
BankAccount.php |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
75.00% covered (warning)
diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html
index 15aec8765..5680ed189 100644
--- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html
+++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php.html
@@ -46,13 +46,13 @@
Total |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
@@ -91,13 +91,13 @@
BankAccount |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
@@ -180,7 +180,7 @@
|
0.00% |
- 0 / 4 |
+ 0 / 3 |
0.00% covered (danger)
@@ -305,7 +305,7 @@
12 | { |
13 | if ($balance >= 0) { |
14 | $this->balance = $balance; |
- 15 | } else { |
+ 15 | } else { |
16 | throw new RuntimeException; |
17 | } |
18 | } |
diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html
index 6a89c22ec..fe4a8a066 100644
--- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html
+++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_branch.html
@@ -46,13 +46,13 @@
Total |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
@@ -91,13 +91,13 @@
BankAccount |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
@@ -180,7 +180,7 @@
|
0.00% |
- 0 / 4 |
+ 0 / 3 |
0.00% covered (danger)
diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html
index aa8f776b2..de13b9a4f 100644
--- a/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html
+++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/BankAccount.php_path.html
@@ -46,13 +46,13 @@
Total |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
@@ -91,13 +91,13 @@
BankAccount |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
@@ -180,7 +180,7 @@
|
0.00% |
- 0 / 4 |
+ 0 / 3 |
0.00% covered (danger)
diff --git a/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html b/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html
index c31d0b7a7..b3616eeec 100644
--- a/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html
+++ b/tests/_files/Report/HTML/PathCoverageForBankAccount/index.html
@@ -46,13 +46,13 @@
Total |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
@@ -90,13 +90,13 @@
BankAccount.php [line] [branch] [path] |
-
- 55.56% covered (warning)
+
+ 62.50% covered (warning)
|
- 55.56% |
- 5 / 9 |
+ 62.50% |
+ 5 / 8 |
42.86% covered (danger)
diff --git a/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml b/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml
index c9209d0e6..b49cdf8ed 100644
--- a/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml
+++ b/tests/_files/Report/XML/CoverageForBankAccount/BankAccount.php.xml
@@ -2,16 +2,16 @@
-
+
-
+
-
+
diff --git a/tests/_files/Report/XML/CoverageForBankAccount/index.xml b/tests/_files/Report/XML/CoverageForBankAccount/index.xml
index ee3df1efc..a18d5d871 100644
--- a/tests/_files/Report/XML/CoverageForBankAccount/index.xml
+++ b/tests/_files/Report/XML/CoverageForBankAccount/index.xml
@@ -13,7 +13,7 @@
-
+
@@ -21,7 +21,7 @@
-
+
diff --git a/tests/_files/source_with_heavy_indentation.php b/tests/_files/source_with_heavy_indentation.php
index 64cea4a10..15f50753e 100644
--- a/tests/_files/source_with_heavy_indentation.php
+++ b/tests/_files/source_with_heavy_indentation.php
@@ -1,11 +1,27 @@
isOne();
+ $xb = 1;
+ $xc = $xa;
+
+ $va
+ =
+ $vb
+ =
+ [
+ $xa,
+ $xb,
+ 1
+ +
+ $xb
+ + 1,
+ ];
+
+ [
+ $v2,
+ $v3
+ ]
+ =
+ u(
+ $xa,
+ $xb,
+ 1
+ +
+ $xc
+ +
+ 1
+ );
+
+ return $v2 === $v3;
+ }
+
+ public function variableBinaryConcat(): bool
+ {
+ $xa = $this->isOne();
+ $xb = 1;
+ $xc = $xa;
+
+ $va
+ =
+ $vb
+ =
+ [
+ $xa,
+ $xb,
+ 1
+ .
+ $xb
+ . 1,
+ ];
+
+ [
+ $v2,
+ $v3
+ ]
+ =
+ u(
+ $xa,
+ $xb,
+ 1
+ .
+ $xc
+ .
+ 1
+ );
+
+ return $v2 === $v3;
+ }
+
+ public function noElse(): int
+ {
+ $res = 0;
+ if (mt_rand() === 0) {
+ return 1;
+ } elseif (mt_rand() === 0) {
+ return 2;
+ } else {
+ $res = 3;
+ }
+
+ return $res;
+ }
+
+ public function noDo(): int
+ {
+ $res = 0;
+ do {
+ if (mt_rand() !== 0) {
+ $res++;
+ }
+ } while (
+ $res
+ <
+ 10
+ );
+
+ return $res;
+ }
+
+ public function noTryNoFinally(): int
+ {
+ $res = 0;
+ try {
+ if (mt_rand() === 0) {
+ throw new \Exception();
+ }
+ } catch (
+ \x\y
+ |
+ \x\z
+ $e
+ ) {
+ $res = 1;
+ } catch (\Error $e) {
+ $res = 1;
+ } finally {
+ $res += 10;
+ }
+
+ return $res;
+ }
+
+ public function switch(): int
+ {
+ switch (
+ 'x'
+ .
+ mt_rand()
+ . 'x'
+ ) {
+ case
+ << 'fi_v',
+ 'omega',
+ ]
+ [
+ 'f'
+ . 'i'
+ ]
+ ;
+ }
+
+ public function emptyArray(): array
+ {
+ return
+ (
+ [
+ ]
+ )
+ ;
+ }
+
+ public function complexAssociativityNa2(): bool
+ {
+ return
+ !
+ !
+ !
+ <<<'EOF'
+ foo
+ foo
+ EOF
+ ;
+ }
+
+ public function unaryMinusNowdoc(): float
+ {
+ return
+ -
+ <<<'EOF'
+ 1.
+ 2
+ EOF
+ ;
+ }
+
+ public
+ function
+ emptyMethod
+ (
+ )
+ :
+ void
+ {
+ }
+
+ public function emptyMethodWithComment(): void
+ {
+ // empty method with comment
+ }
+
+ public function simpleConstArrayEmpty(): array
+ {
+ return
+ [
+ // empty array with comment
+ ];
+ }
+
+ public function nestedConstArrayEmpty(): array
+ {
+ return
+ [
+ [
+ // empty subarray with comment
+ ]
+ ];
+ }
+
+ public function nestedConstArrayOne(): array
+ {
+ return
+ [
+ [
+ <<<'EOF'
+ 1
+ EOF,
+ ]
+ ];
+ }
+
+ public function nestedConstArrayTwo(): array
+ {
+ return
+ [
+ [
+ <<<'EOF'
+ 1
+ EOF,
+ 2,
+ ]
+ ];
+ }
+
+ public function nestedArrayWithExecutableInKey(): array
+ {
+ return
+ [
+ [
+ 1,
+ phpversion()
+ =>
+ 2,
+ ]
+ ];
+ }
}
diff --git a/tests/_files/source_with_oneline_annotations.php b/tests/_files/source_with_oneline_annotations.php
index 7b1cb1cbd..7d3981e0a 100644
--- a/tests/_files/source_with_oneline_annotations.php
+++ b/tests/_files/source_with_oneline_annotations.php
@@ -34,3 +34,7 @@ function baz()
print '*';
}
+
+function xyz()
+{
+}
diff --git a/tests/tests/CodeCoverageTest.php b/tests/tests/CodeCoverageTest.php
index 8de789819..80c8c8f92 100644
--- a/tests/tests/CodeCoverageTest.php
+++ b/tests/tests/CodeCoverageTest.php
@@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\CodeCoverage;
+use function array_fill;
use SebastianBergmann\CodeCoverage\Driver\Driver;
use SebastianBergmann\CodeCoverage\Driver\Selector;
use SebastianBergmann\Environment\Runtime;
@@ -108,7 +109,6 @@ public function testExcludeNonExecutableLines(): void
8 => [],
13 => [],
14 => [],
- 15 => [],
16 => [],
22 => [],
24 => [],
diff --git a/tests/tests/Data/ProcessedCodeCoverageDataTest.php b/tests/tests/Data/ProcessedCodeCoverageDataTest.php
index 13758f18a..206634041 100644
--- a/tests/tests/Data/ProcessedCodeCoverageDataTest.php
+++ b/tests/tests/Data/ProcessedCodeCoverageDataTest.php
@@ -40,7 +40,7 @@ public function testMergeWithPathCoverage(): void
public function testMergeWithPathCoverageIntoEmpty(): void
{
- $coverage = new ProcessedCodeCoverageData();
+ $coverage = new ProcessedCodeCoverageData;
$coverage->merge($this->getPathCoverageForBankAccount()->getData());
diff --git a/tests/tests/Data/RawCodeCoverageDataTest.php b/tests/tests/Data/RawCodeCoverageDataTest.php
index ae4e48803..43aab64a1 100644
--- a/tests/tests/Data/RawCodeCoverageDataTest.php
+++ b/tests/tests/Data/RawCodeCoverageDataTest.php
@@ -272,7 +272,6 @@ public function testUseStatementsAreUncovered(): void
[
12,
14,
- 15,
16,
18,
],
@@ -300,7 +299,6 @@ public function testInterfacesAreUncovered(): void
[
7,
9,
- 10,
11,
13,
],
@@ -314,6 +312,7 @@ public function testInlineCommentsKeepTheLine(): void
$this->assertEquals(
[
+ 13,
19,
22,
26,
@@ -322,6 +321,7 @@ public function testInlineCommentsKeepTheLine(): void
32,
33,
35,
+ 40,
],
array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingFileAnalyser(true, true))->lineCoverage()[$file])
);
@@ -333,44 +333,98 @@ public function testHeavyIndentationIsHandledCorrectly(): void
$this->assertEquals(
[
- 9,
- 12,
- 16,
- 18,
+ 14,
19,
- 24,
+ // line 22 is unstable - not in xdebug output if script is cached by opcache
25,
- 28,
- 31,
- 36,
+ // line 28 is unstable - const coverage depends on autoload order - https://github.com/sebastianbergmann/php-code-coverage/issues/889
+ 32,
+ 34,
+ 35,
40,
- 46,
- 48,
- 54,
- 60,
+ 41,
+ 44,
+ 47,
+ 56,
+ 62,
64,
- 71,
- 83,
- 85,
+ 70,
+ 76,
87,
- 89,
- 91,
- 93,
95,
+ 96,
97,
99,
101,
- 116,
- 120,
- 123,
- 125, // This shouldn't be marked as LoC, but it's high unlikely to happen IRL to have $var = []; on multiple lines
+ // line 108 is unstable - variable has no coverage if it holds const expr - https://github.com/sebastianbergmann/php-code-coverage/issues/953
+ 113,
+ // array destruct element, should be present 114
+ 117,
+ 127,
132,
- 135,
- 139,
- 143,
- 149,
- 153,
- 159,
+ 133,
+ 134,
+ 136,
+ 138,
+ // line 145 is unstable - same reason as line 108
+ 150,
+ // array destruct element, should be present 151 - same reason as line 114
+ 154,
+ 164,
+ 169,
+ 170,
+ 171,
+ 172,
+ 173,
+ // line 174 is else statement, not in xdebug output (only if/elseif conditions are covered)
+ 175,
+ 178,
+ 183,
+ 185,
+ 186,
+ 191,
+ 194,
+ 199,
+ // line 200 is try statement, not in xdebug output (only catch condition is covered)
+ 201,
+ 202,
+ 205,
+ 210,
+ 211,
+ 212,
+ // line 213 is finally statement, not in xdebug output (only catch condition is covered)
+ 214,
+ 217,
+ 225,
+ 230,
+ 232,
+ 234,
+ 235,
+ 236,
+ 237,
+ 239,
+ // line 240 is default case, not in xdebug output (only cases with condition are covered)
+ 241,
+ 244,
+ 253,
+ 255,
+ 257,
+ 259,
+ 261,
+ 263,
+ 265,
+ 267,
+ 269,
+ 271,
+ 293,
+ 298,
+ 302,
+ 305,
+ 309,
+ 313,
+ 319,
+ 323,
+ 329,
],
array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingFileAnalyser(true, true))->lineCoverage()[$file])
);
@@ -460,6 +514,40 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
226,
235,
244,
+ 252,
+ 261,
+ 269,
+ 278,
+ 293,
+ 304,
+ 314,
+ 321,
+ 323,
+ 324,
+ 325,
+ 327,
+ 340,
+ 351,
+ 370,
+ 377,
+ 390,
+ 402,
+ 414,
+ 425,
+ 437,
+ 442,
+ 444,
+ 459,
+ 469,
+ 481,
+ 492,
+ 506,
+ 511,
+ 518,
+ 527,
+ 537,
+ 549,
+ 562,
],
array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingFileAnalyser(true, true))->lineCoverage()[$file])
);
diff --git a/tests/tests/Node/BuilderTest.php b/tests/tests/Node/BuilderTest.php
index dba2fd28e..681d189f3 100644
--- a/tests/tests/Node/BuilderTest.php
+++ b/tests/tests/Node/BuilderTest.php
@@ -32,7 +32,7 @@ public function testSomething(): void
$expectedPath = rtrim(TEST_FILES_PATH, DIRECTORY_SEPARATOR);
$this->assertEquals($expectedPath, $root->name());
$this->assertEquals($expectedPath, $root->pathAsString());
- $this->assertEquals(9, $root->numberOfExecutableLines());
+ $this->assertEquals(8, $root->numberOfExecutableLines());
$this->assertEquals(5, $root->numberOfExecutedLines());
$this->assertEquals(1, $root->numberOfClasses());
$this->assertEquals(0, $root->numberOfTestedClasses());
@@ -40,7 +40,7 @@ public function testSomething(): void
$this->assertEquals(3, $root->numberOfTestedMethods());
$this->assertEquals('0.00%', $root->percentageOfTestedClasses()->asString());
$this->assertEquals('75.00%', $root->percentageOfTestedMethods()->asString());
- $this->assertEquals('55.56%', $root->percentageOfExecutedLines()->asString());
+ $this->assertEquals('62.50%', $root->percentageOfExecutedLines()->asString());
$this->assertEquals(0, $root->numberOfFunctions());
$this->assertEquals(0, $root->numberOfTestedFunctions());
$this->assertNull($root->parent());
@@ -73,7 +73,7 @@ public function testSomething(): void
'signature' => 'setBalance($balance)',
'startLine' => 11,
'endLine' => 18,
- 'executableLines' => 4,
+ 'executableLines' => 3,
'executedLines' => 0,
'executableBranches' => 0,
'executedBranches' => 0,
@@ -122,15 +122,15 @@ public function testSomething(): void
],
],
'startLine' => 2,
- 'executableLines' => 9,
+ 'executableLines' => 8,
'executedLines' => 5,
'executableBranches' => 0,
'executedBranches' => 0,
'executablePaths' => 0,
'executedPaths' => 0,
'ccn' => 5,
- 'coverage' => 55.55555555555556,
- 'crap' => '7.19',
+ 'coverage' => 62.5,
+ 'crap' => '6.32',
'link' => 'BankAccount.php.html#2',
'className' => 'BankAccount',
'namespace' => '',
diff --git a/tests/tests/Report/CoberturaTest.php b/tests/tests/Report/CoberturaTest.php
index 7bfca02dd..131ef5a76 100644
--- a/tests/tests/Report/CoberturaTest.php
+++ b/tests/tests/Report/CoberturaTest.php
@@ -70,6 +70,6 @@ private function validateReport(string $coberturaReport): void
{
$document = (new DOMDocument);
$this->assertTrue($document->loadXML($coberturaReport));
- $this->assertTrue($document->validate());
+ $this->assertTrue(@$document->validate());
}
}
diff --git a/tests/tests/StaticAnalysis/CodeUnitFindingVisitorTest.php b/tests/tests/StaticAnalysis/CodeUnitFindingVisitorTest.php
index ffe06c8df..1c9d3aa2b 100644
--- a/tests/tests/StaticAnalysis/CodeUnitFindingVisitorTest.php
+++ b/tests/tests/StaticAnalysis/CodeUnitFindingVisitorTest.php
@@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\CodeCoverage\StaticAnalysis;
+use function assert;
use function file_get_contents;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\NameResolver;
| | | | | | | | | |