Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions build/scripts/generate-expectations.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function formatMatches(string $format, string $subject): bool

$scenarios = [
'CoverageForBankAccount' => $provider->lineCoverageForBankAccount(...),
'CoverageForBankAccountWithTestSizes' => $provider->coverageForBankAccountWithVariousTestSizesAndStatuses(...),
'PathCoverageForBankAccount' => $provider->pathCoverageForBankAccount(...),
'PathCoverageForSourceWithoutNamespace' => $provider->pathCoverageForSourceWithoutNamespace(...),
'CoverageForFileWithIgnoredLines' => $provider->coverageForFileWithIgnoredLines(...),
Expand Down
10 changes: 10 additions & 0 deletions src/Data/ProcessedClassType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
*/
namespace SebastianBergmann\CodeCoverage\Data;

use SebastianBergmann\CodeCoverage\Test\TestSizes;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @phpstan-import-type TestSizeSet from TestSizes
* @phpstan-import-type TestSizeCounts from TestSizes
*/
final class ProcessedClassType
{
Expand All @@ -26,6 +31,11 @@ final class ProcessedClassType
public readonly int $startLine;
public int $executableLines;
public int $executedLines;

/**
* @var TestSizeCounts
*/
public array $executedLinesByTestSize = TestSizes::ZERO_COUNTS;
public int $executableBranches;
public int $executedBranches;
public int $executablePaths;
Expand Down
10 changes: 10 additions & 0 deletions src/Data/ProcessedFunctionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
*/
namespace SebastianBergmann\CodeCoverage\Data;

use SebastianBergmann\CodeCoverage\Test\TestSizes;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @phpstan-import-type TestSizeSet from TestSizes
* @phpstan-import-type TestSizeCounts from TestSizes
*/
final class ProcessedFunctionType
{
Expand All @@ -23,6 +28,11 @@ final class ProcessedFunctionType
public readonly int $endLine;
public int $executableLines;
public int $executedLines;

/**
* @var TestSizeCounts
*/
public array $executedLinesByTestSize = TestSizes::ZERO_COUNTS;
public int $executableBranches;
public int $executedBranches;
public int $executablePaths;
Expand Down
10 changes: 10 additions & 0 deletions src/Data/ProcessedMethodType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
*/
namespace SebastianBergmann\CodeCoverage\Data;

use SebastianBergmann\CodeCoverage\Test\TestSizes;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @phpstan-import-type TestSizeSet from TestSizes
* @phpstan-import-type TestSizeCounts from TestSizes
*/
final class ProcessedMethodType
{
Expand All @@ -23,6 +28,11 @@ final class ProcessedMethodType
public readonly int $endLine;
public int $executableLines;
public int $executedLines;

/**
* @var TestSizeCounts
*/
public array $executedLinesByTestSize = TestSizes::ZERO_COUNTS;
public int $executableBranches;
public int $executedBranches;
public int $executablePaths;
Expand Down
10 changes: 10 additions & 0 deletions src/Data/ProcessedTraitType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
*/
namespace SebastianBergmann\CodeCoverage\Data;

use SebastianBergmann\CodeCoverage\Test\TestSizes;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @phpstan-import-type TestSizeSet from TestSizes
* @phpstan-import-type TestSizeCounts from TestSizes
*/
final class ProcessedTraitType
{
Expand All @@ -26,6 +31,11 @@ final class ProcessedTraitType
public readonly int $startLine;
public int $executableLines;
public int $executedLines;

/**
* @var TestSizeCounts
*/
public array $executedLinesByTestSize = TestSizes::ZERO_COUNTS;
public int $executableBranches;
public int $executedBranches;
public int $executablePaths;
Expand Down
55 changes: 55 additions & 0 deletions src/Node/AbstractNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
use SebastianBergmann\CodeCoverage\Data\ProcessedFunctionType;
use SebastianBergmann\CodeCoverage\Data\ProcessedTraitType;
use SebastianBergmann\CodeCoverage\StaticAnalysis\LinesOfCode;
use SebastianBergmann\CodeCoverage\Test\TestSizes;
use SebastianBergmann\CodeCoverage\Util\Percentage;

/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for phpunit/php-code-coverage
*
* @phpstan-import-type TestSizeSet from TestSizes
*/
abstract class AbstractNode implements Countable
{
Expand Down Expand Up @@ -136,6 +139,17 @@ public function percentageOfExecutedLines(): Percentage
);
}

/**
* @param TestSizeSet $testSizes
*/
public function percentageOfExecutedLinesByTestSize(int $testSizes): Percentage
{
return Percentage::fromFractionAndTotal(
$this->numberOfExecutedLinesByTestSize($testSizes),
$this->numberOfExecutableLines(),
);
}

public function percentageOfExecutedBranches(): Percentage
{
return Percentage::fromFractionAndTotal(
Expand All @@ -162,6 +176,14 @@ public function numberOfTestedClassesAndTraits(): int
return $this->numberOfTestedClasses() + $this->numberOfTestedTraits();
}

/**
* @param TestSizeSet $testSizes
*/
public function numberOfTestedClassesAndTraitsByTestSize(int $testSizes): int
{
return $this->numberOfTestedClassesByTestSize($testSizes) + $this->numberOfTestedTraitsByTestSize($testSizes);
}

/**
* @return array<string, ProcessedClassType|ProcessedTraitType>
*/
Expand All @@ -180,6 +202,14 @@ public function numberOfTestedFunctionsAndMethods(): int
return $this->numberOfTestedFunctions() + $this->numberOfTestedMethods();
}

/**
* @param TestSizeSet $testSizes
*/
public function numberOfTestedFunctionsAndMethodsByTestSize(int $testSizes): int
{
return $this->numberOfTestedFunctionsByTestSize($testSizes) + $this->numberOfTestedMethodsByTestSize($testSizes);
}

/**
* @return non-negative-int
*/
Expand Down Expand Up @@ -219,6 +249,11 @@ abstract public function numberOfExecutableLines(): int;

abstract public function numberOfExecutedLines(): int;

/**
* @param TestSizeSet $testSizes
*/
abstract public function numberOfExecutedLinesByTestSize(int $testSizes): int;

abstract public function numberOfExecutableBranches(): int;

abstract public function numberOfExecutedBranches(): int;
Expand All @@ -233,18 +268,38 @@ abstract public function numberOfClasses(): int;

abstract public function numberOfTestedClasses(): int;

/**
* @param TestSizeSet $testSizes
*/
abstract public function numberOfTestedClassesByTestSize(int $testSizes): int;

abstract public function numberOfTraits(): int;

abstract public function numberOfTestedTraits(): int;

/**
* @param TestSizeSet $testSizes
*/
abstract public function numberOfTestedTraitsByTestSize(int $testSizes): int;

abstract public function numberOfMethods(): int;

abstract public function numberOfTestedMethods(): int;

/**
* @param TestSizeSet $testSizes
*/
abstract public function numberOfTestedMethodsByTestSize(int $testSizes): int;

abstract public function numberOfFunctions(): int;

abstract public function numberOfTestedFunctions(): int;

/**
* @param TestSizeSet $testSizes
*/
abstract public function numberOfTestedFunctionsByTestSize(int $testSizes): int;

private function processId(): void
{
if ($this->parent === null) {
Expand Down
Loading