Skip to content

Commit

Permalink
Fix usage of code coverage checker in project (#3)
Browse files Browse the repository at this point in the history
* Fix usage of code coverage checker in project

* Fix code coverage checker for 0 lines
  • Loading branch information
alexander-schranz authored Aug 5, 2020
1 parent 301b523 commit 2292bfb
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bin/code-coverage-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@

$loader = require $autoloaderFile;

$phpunitBridgeDirectory = dirname(realpath($autoloaderFile)) . '/bin/.phpunit';

if (is_dir($phpunitBridgeDirectory)) {

$phpunitBridgeDirectories = [
dirname(realpath($autoloaderFile)) . '/bin/.phpunit',
dirname(dirname(realpath($autoloaderFile))) . '/bin/.phpunit',
];

foreach ($phpunitBridgeDirectories as $phpunitBridgeDirectory) {
if (!is_dir($phpunitBridgeDirectory)) {
continue;
}

$files = scandir($phpunitBridgeDirectory);

foreach ($files as $file) {
Expand All @@ -36,6 +44,8 @@
&& file_exists($phpunitAutoloader)
) {
require $phpunitAutoloader;

break 2;
}
}
}
Expand Down Expand Up @@ -93,7 +103,7 @@

$message = sprintf(
'Line Coverage for all included files: %.2F%% (%d/%d).',
$totalCoveredLines / $totalExecutableLines * 100,
$totalExecutableLines ? $totalCoveredLines / $totalExecutableLines * 100 : 100,
$totalCoveredLines,
$totalExecutableLines
);
Expand Down

0 comments on commit 2292bfb

Please sign in to comment.