Skip to content

Line coverage stubs: be consistent with actual xDebug/PCOV output #891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2022
Merged
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
32 changes: 32 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,46 @@ protected function getLineCoverageXdebugDataForBankAccount()
RawCodeCoverageData::fromXdebugWithoutPathCoverage([
TEST_FILES_PATH . 'BankAccount.php' => [
8 => 1,
9 => -2,
13 => 1,
14 => -1,
15 => -1,
Comment on lines +55 to +56
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference:

protected function setBalance($balance)
{
if ($balance >= 0) {
$this->balance = $balance;
} else {
throw new RuntimeException;
}
}

Line 14

Line 14 is always reported by each driver. Not having it here can introduce a bug on CC merging in the future

Line 15

This line is not reported by any driver, but I kept it here because removing it would fail pretty much every test in this library.
I've checked each of them, and removing this reported line to be consistent with drivers output adds no value to the test suite.

16 => 1,
18 => -1,
29 => 1,
31 => -1,
32 => -2,
],
]),
RawCodeCoverageData::fromXdebugWithoutPathCoverage([
TEST_FILES_PATH . 'BankAccount.php' => [
8 => 1,
9 => -2,
13 => 1,
14 => -1,
15 => -1,
16 => 1,
18 => -1,
22 => 1,
24 => -1,
25 => -2,
],
]),
RawCodeCoverageData::fromXdebugWithoutPathCoverage([
TEST_FILES_PATH . 'BankAccount.php' => [
8 => 1,
9 => -2,
13 => 1,
14 => 1,
15 => 1,
16 => -1,
18 => 1,
22 => 1,
24 => 1,
25 => -2,
29 => 1,
31 => 1,
32 => -2,
],
]),
];
Expand Down Expand Up @@ -276,9 +292,15 @@ protected function getPathCoverageXdebugDataForBankAccount()
TEST_FILES_PATH . 'BankAccount.php' => [
'lines' => [
8 => 1,
9 => -2,
13 => 1,
14 => -1,
15 => -1,
16 => 1,
18 => -1,
29 => 1,
31 => -1,
32 => -2,
],
'functions' => [
'BankAccount->depositMoney' => [
Expand Down Expand Up @@ -457,9 +479,15 @@ protected function getPathCoverageXdebugDataForBankAccount()
TEST_FILES_PATH . 'BankAccount.php' => [
'lines' => [
8 => 1,
9 => -2,
13 => 1,
14 => -1,
15 => -1,
16 => 1,
18 => -1,
22 => 1,
24 => -1,
25 => -2,
],
'functions' => [
'BankAccount->depositMoney' => [
Expand Down Expand Up @@ -638,14 +666,18 @@ protected function getPathCoverageXdebugDataForBankAccount()
TEST_FILES_PATH . 'BankAccount.php' => [
'lines' => [
8 => 1,
9 => -2,
13 => 1,
14 => 1,
15 => 1,
16 => -1,
18 => 1,
22 => 1,
24 => 1,
25 => -2,
29 => 1,
31 => 1,
32 => -2,
],
'functions' => [
'BankAccount->depositMoney' => [
Expand Down