From 1fcbc8a8b901db7ccfe1d8f9c2ff7b1768a264a9 Mon Sep 17 00:00:00 2001 From: tmont Date: Wed, 1 Jul 2009 10:43:34 +0000 Subject: [PATCH] fixed a couple more bugs, noted another, and committed a few tests --- .../framework/reporting/CoverageFilter.php | 4 +- .../framework/reporting/CoverageReporter.php | 5 ++ src/Testify/util/Util.php | 3 - tests/AllTests.php | 14 ++++ tests/Testify/util/UtilTest.php | 65 +++++++++++++++++++ 5 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 tests/AllTests.php create mode 100644 tests/Testify/util/UtilTest.php diff --git a/src/Testify/framework/reporting/CoverageFilter.php b/src/Testify/framework/reporting/CoverageFilter.php index 486a9d2..5eb3415 100644 --- a/src/Testify/framework/reporting/CoverageFilter.php +++ b/src/Testify/framework/reporting/CoverageFilter.php @@ -34,7 +34,9 @@ public static function filter(array $data) { foreach ($data as $file => $arr) { - if (in_array($file, self::$files)) { + if (strpos($file, ' : runtime-created function') !== false) { + unset($data[$file]); + } else if (in_array($file, self::$files)) { unset($data[$file]); } else { foreach (self::$directories as $dir) { diff --git a/src/Testify/framework/reporting/CoverageReporter.php b/src/Testify/framework/reporting/CoverageReporter.php index 15feeb3..5e4c312 100644 --- a/src/Testify/framework/reporting/CoverageReporter.php +++ b/src/Testify/framework/reporting/CoverageReporter.php @@ -288,6 +288,10 @@ return file_put_contents($newFile, $template); } + /** + * @todo If there are no files in the root directory (e.g. only directories) + * then index.html does not get generated + */ private static function writeHtmlDirectories($coverageDir, $baseDir, array $coverageData, $renderer) { $dirData = array(); foreach ($coverageData as $file => $data) { @@ -400,6 +404,7 @@ $template ); + //echo $dir . "\n"; $fileName = ($dir === DIRECTORY_SEPARATOR) ? 'index.html' : str_replace(DIRECTORY_SEPARATOR, '-', $dir) . '.html'; file_put_contents($coverageDir . DIRECTORY_SEPARATOR . $fileName, $temp); } diff --git a/src/Testify/util/Util.php b/src/Testify/util/Util.php index 88987c3..5fd5118 100644 --- a/src/Testify/util/Util.php +++ b/src/Testify/util/Util.php @@ -254,9 +254,6 @@ } public static function getClassNamesFromFile($file) { - if (!is_file($file)) { - return array(); - } $tokens = token_get_all(file_get_contents($file)); $classes = array(); for ($i = 0, $len = count($tokens); $i < $len; $i++) { diff --git a/tests/AllTests.php b/tests/AllTests.php new file mode 100644 index 0000000..9fabf4e --- /dev/null +++ b/tests/AllTests.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/tests/Testify/util/UtilTest.php b/tests/Testify/util/UtilTest.php new file mode 100644 index 0000000..996eb58 --- /dev/null +++ b/tests/Testify/util/UtilTest.php @@ -0,0 +1,65 @@ + \ No newline at end of file