Skip to content

Commit

Permalink
Remove deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 7, 2024
1 parent 6fd234d commit b25c249
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 377 deletions.
1 change: 1 addition & 0 deletions ChangeLog-12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

### Removed

* Methods `CodeCoverage::includeUncoveredFiles()` and `CodeCoverage::excludeUncoveredFiles()`
* Optional argument `$linesToBeUsed` of `CodeCoverage::stop()` and `CodeCoverage::append()` methods
* This component is no longer supported on PHP 8.2

Expand Down
21 changes: 1 addition & 20 deletions src/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ final class CodeCoverage
private readonly Filter $filter;
private readonly Wizard $wizard;
private bool $checkForUnintentionallyCoveredCode = false;
private bool $includeUncoveredFiles = true;
private bool $ignoreDeprecatedCode = false;
private ?string $currentId = null;
private ?TestSize $currentSize = null;
Expand Down Expand Up @@ -122,9 +121,7 @@ public function filter(): Filter
public function getData(bool $raw = false): ProcessedCodeCoverageData
{
if (!$raw) {
if ($this->includeUncoveredFiles) {
$this->addUncoveredFilesFromFilter();
}
$this->addUncoveredFilesFromFilter();
}

return $this->data;
Expand Down Expand Up @@ -271,22 +268,6 @@ public function disableCheckForUnintentionallyCoveredCode(): void
$this->checkForUnintentionallyCoveredCode = false;
}

/**
* @deprecated
*/
public function includeUncoveredFiles(): void
{
$this->includeUncoveredFiles = true;
}

/**
* @deprecated
*/
public function excludeUncoveredFiles(): void
{
$this->includeUncoveredFiles = false;
}

public function enableAnnotationsForIgnoringCode(): void
{
$this->useAnnotationsForIgnoringCode = true;
Expand Down
251 changes: 0 additions & 251 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1165,123 +1165,6 @@ protected function getPathCoverageForSourceWithoutNamespace(): CodeCoverage
return $coverage;
}

protected function getXdebugDataForNamespacedBankAccount()
{
return [
RawCodeCoverageData::fromXdebugWithoutPathCoverage([
TEST_FILES_PATH . 'NamespacedBankAccount.php' => [
13 => 1,
14 => -2,
18 => -1,
19 => -1,
20 => -1,
21 => -1,
23 => -1,
27 => -1,
29 => -1,
30 => -2,
34 => -1,
36 => -1,
37 => -2,
],
]),
RawCodeCoverageData::fromXdebugWithoutPathCoverage([
TEST_FILES_PATH . 'NamespacedBankAccount.php' => [
13 => 1,
18 => 1,
21 => 1,
34 => 1,
],
]),
RawCodeCoverageData::fromXdebugWithoutPathCoverage([
TEST_FILES_PATH . 'NamespacedBankAccount.php' => [
13 => 1,
18 => 1,
21 => 1,
27 => 1,
],
]),
RawCodeCoverageData::fromXdebugWithoutPathCoverage([
TEST_FILES_PATH . 'NamespacedBankAccount.php' => [
13 => 1,
18 => 1,
19 => 1,
20 => 1,
23 => 1,
27 => 1,
29 => 1,
34 => 1,
36 => 1,
],
]),
];
}

protected function getLineCoverageForNamespacedBankAccount(): CodeCoverage
{
$data = $this->getXdebugDataForNamespacedBankAccount();

$stub = $this->createStub(Driver::class);

$stub->method('stop')
->willReturn(...$data);

$filter = new Filter;
$filter->includeFile(TEST_FILES_PATH . 'NamespacedBankAccount.php');

$coverage = new CodeCoverage($stub, $filter);

$coverage->start(
'BankAccountTest::testBalanceIsInitiallyZero',
null,
true
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'NamespacedBankAccount.php' => range(11, 14)]
);

$coverage->start(
'BankAccountTest::testBalanceCannotBecomeNegative'
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'NamespacedBankAccount.php' => range(32, 37)]
);

$coverage->start(
'BankAccountTest::testBalanceCannotBecomeNegative2'
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'NamespacedBankAccount.php' => range(25, 30)]
);

$coverage->start(
'BankAccountTest::testDepositWithdrawMoney'
);

$coverage->stop(
true,
null,
[
TEST_FILES_PATH . 'NamespacedBankAccount.php' => array_merge(
range(11, 14),
range(25, 30),
range(32, 37)
),
]
);

return $coverage;
}

protected function getLineCoverageForBankAccountForFirstTwoTests(): CodeCoverage
{
$data = $this->getLineCoverageXdebugDataForBankAccount();
Expand Down Expand Up @@ -1867,138 +1750,4 @@ protected function removeTemporaryFiles(): void
$fileInfo->isDir() ? rmdir($pathname) : unlink($pathname);
}
}

protected function getCoverageForFilesWithUncoveredIncluded(): CodeCoverage
{
$data = $this->getLineCoverageXdebugDataForBankAccount();

$stub = $this->createStub(Driver::class);

$stub->method('stop')
->willReturn(...$data);

$filter = new Filter;
$filter->includeFile(TEST_FILES_PATH . 'BankAccount.php');
$filter->includeFile(TEST_FILES_PATH . 'NamespacedBankAccount.php');

$coverage = new CodeCoverage($stub, $filter);
$coverage->includeUncoveredFiles();

$coverage->start(
'BankAccountTest::testBalanceIsInitiallyZero',
null,
true
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)]
);

$coverage->start(
'BankAccountTest::testBalanceCannotBecomeNegative'
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)]
);

$coverage->start(
'BankAccountTest::testBalanceCannotBecomeNegative2'
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)]
);

$coverage->start(
'BankAccountTest::testDepositWithdrawMoney'
);

$coverage->stop(
true,
null,
[
TEST_FILES_PATH . 'BankAccount.php' => array_merge(
range(6, 9),
range(20, 25),
range(27, 32)
),
]
);

return $coverage;
}

protected function getCoverageForFilesWithUncoveredExcluded(): CodeCoverage
{
$data = $this->getLineCoverageXdebugDataForBankAccount();

$stub = $this->createStub(Driver::class);

$stub->method('stop')
->willReturn(...$data);

$filter = new Filter;
$filter->includeFile(TEST_FILES_PATH . 'BankAccount.php');
$filter->includeFile(TEST_FILES_PATH . 'NamespacedBankAccount.php');

$coverage = new CodeCoverage($stub, $filter);
$coverage->excludeUncoveredFiles();

$coverage->start(
'BankAccountTest::testBalanceIsInitiallyZero',
null,
true
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'BankAccount.php' => range(6, 9)]
);

$coverage->start(
'BankAccountTest::testBalanceCannotBecomeNegative'
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'BankAccount.php' => range(27, 32)]
);

$coverage->start(
'BankAccountTest::testBalanceCannotBecomeNegative2'
);

$coverage->stop(
true,
null,
[TEST_FILES_PATH . 'BankAccount.php' => range(20, 25)]
);

$coverage->start(
'BankAccountTest::testDepositWithdrawMoney'
);

$coverage->stop(
true,
null,
[
TEST_FILES_PATH . 'BankAccount.php' => array_merge(
range(6, 9),
range(20, 25),
range(27, 32)
),
]
);

return $coverage;
}
}
14 changes: 0 additions & 14 deletions tests/_files/NamespacedBankAccount-text-with-colors.txt

This file was deleted.

14 changes: 0 additions & 14 deletions tests/_files/NamespacedBankAccount-text.txt

This file was deleted.

38 changes: 0 additions & 38 deletions tests/_files/NamespacedBankAccount.php

This file was deleted.

Loading

0 comments on commit b25c249

Please sign in to comment.