diff --git a/tests/run.php b/tests/run.php
index 16155074f..30d8c70f1 100644
--- a/tests/run.php
+++ b/tests/run.php
@@ -414,52 +414,65 @@ if(PHP_SAPI === "cli"){
}else{
$reporter = new MyReporter();
}
+//uncomment this to run codecoverage
+//xdebug_start_code_coverage();
$test->run($reporter);
+/* remote to enable coverage
$path = Doctrine::getPath() . DIRECTORY_SEPARATOR;
?>
-
class |
coverage |
+ $lines) {
-
$pos = strpos($file, $path);
-
- $values = array_values($lines);
- $i = count($values);
- $covered = 0;
- while ($i--) {
- if ($values[$i] > 0) {
- $covered++;
- }
+ if($pos === false && $pos !== 0){
+ continue;
}
- if ($pos !== false) {
- $class = str_replace(DIRECTORY_SEPARATOR, '_', substr($file, strlen($path), -4));
+ $covered = 0;
+ $coveredLines = array_values($lines);
+ array_walk($coveredLines, "countCovered");
+ $class = str_replace(DIRECTORY_SEPARATOR, '_', substr($file, strlen($path), -4));
+ if (strpos($class, '_Interface')) {
+ continue;
+ }
- if (strpos($class, '_Interface')) {
- continue;
- }
+ if(!class_exists($class)){
+ continue;
+ }
+ $refl = new ReflectionClass($class);
+ $total = 0;
+ foreach ($refl->getMethods() as $method) {
+ $total += ($method->getEndLine() - $method->getStartLine());
+ }
+ $totallines += $total;
+ $totalcovered += $covered;
- $refl = new ReflectionClass($class);
- $total = 0;
- foreach ($refl->getMethods() as $method) {
- $total += ($method->getEndLine() - $method->getStartLine());
- }
- if ($total === 0) {
- $total = 1;
- }
- print "" . $class . " | " . round(($covered / $total) * 100, 2) . " % |
";
+ if ($total === 0) {
+ $total = 1;
+ }
+ print "" . $class . " | " . round(($covered / $total) * 100, 2) . " % |
";
+}
+if ($totallines === 0) {
+ $totallines = 1;
+}
+print "TOTAL | " . round(($totalcovered / $totallines) * 100, 2) . " % |
";
+
+function countCovered($value, $key){
+ global $covered;
+ if($value >= 1){
+ $covered++;
}
}
-*/
?>