diff --git a/src/TUnit/framework/reporting/CoverageReporter.php b/src/TUnit/framework/reporting/CoverageReporter.php index 98a0723..585ed80 100644 --- a/src/TUnit/framework/reporting/CoverageReporter.php +++ b/src/TUnit/framework/reporting/CoverageReporter.php @@ -264,7 +264,7 @@ foreach ($coverageData as $file => $data) { $dirs = preg_split('@\\' . DIRECTORY_SEPARATOR . '@', str_replace($baseDir, '', dirname($file) . DIRECTORY_SEPARATOR), -1, PREG_SPLIT_NO_EMPTY); if (empty($dirs)) { - continue; + $dirs[] = ''; } $loc = count($data); @@ -303,7 +303,7 @@ $link = ''; $subdirs = array(); foreach ($dirData as $dir2 => $data2) { - if (substr($dir2, 0, strrpos($dir2, DIRECTORY_SEPARATOR)) === $dir) { + if ($dir === DIRECTORY_SEPARATOR || substr($dir2, 0, strrpos($dir2, DIRECTORY_SEPARATOR)) === $dir) { //this is a direct subdirectory $subdirs[] = $dir2; } @@ -313,6 +313,9 @@ //create directory info foreach ($subdirs as $subdir) { + if ($subdir === DIRECTORY_SEPARATOR) { + continue; + } $subdata = $dirData[$subdir]; $info .= '' . basename($subdir) . ''; @@ -353,7 +356,7 @@ $template ); - $fileName = str_replace(DIRECTORY_SEPARATOR, '-', $dir) . '.html'; + $fileName = ($dir === DIRECTORY_SEPARATOR) ? 'index.html' : str_replace(DIRECTORY_SEPARATOR, '-', $dir) . '.html'; file_put_contents($coverageDir . DIRECTORY_SEPARATOR . $fileName, $temp); } } @@ -367,7 +370,11 @@ $dirs = preg_split('@\\' . DIRECTORY_SEPARATOR . '@', str_replace($baseDir, '', dirname($path) . DIRECTORY_SEPARATOR), -1, PREG_SPLIT_NO_EMPTY); $path = ''; foreach ($dirs as $dir) { - $path = $path . '-' . $dir; + if (empty($dir)) { + $path = 'index.html'; + } else { + $path = $path . '-' . $dir; + } if ($oneLink) { $link = $path; } else { @@ -375,9 +382,6 @@ } } - // print_r($dirs); - // echo 'asdf: ' . $link . "\n\n"; - return $link; }