diff --git a/tests/cc.php b/tests/cc.php
index 77f5e4f73..f864f9bbc 100644
--- a/tests/cc.php
+++ b/tests/cc.php
@@ -1,108 +1,190 @@
+
+
+
+
+
+Coverage for ' . $_GET["file"] . '';
+ echo 'Back to coverage report';
+ $reporter->showFile($_GET["file"]);
+}else{
+?>
+ Coverage report for Doctrine
+ Default mode shows results sorted by perentage. This can be changed with order = covered|total|maybe|notcovered|percentage and desc=true GET variables
+
+ | Percentage | Total | Covered | Maybe | Not Covered | |
+showSummary();
+ echo "
";
+}
+?>
+
+
+
+path = $result["path"];
+ $this->coverage = $result["coverage"];
+
+ $this->sortBy ="percentage"; // default sort
}
+ public function showFile($fileName)
+ {
+ $key = $this->path . $fileName;
+ $html = '';
+ if( !isset( $this->coverage[$key]))
+ {
+ echo 'No coverage for this file
';
+ }
+ $coveredLines = $this->coverage[$key];
+ $fileArray = file(Doctrine::getPath() . "/".$fileName);
+ $html .= '' . "\n";
+ foreach( $fileArray as $num => $line){
+ $linenum = $num+1;
+ $html .= '- ' . $linenum . '
' . "\n";
+ $class ="normal";
+ if( isset($coveredLines[$linenum]) && $coveredLines[$linenum] == 1){
+ $class = "covered";
+ }else if( isset($coveredLines[$linenum]) && $coveredLines[$linenum] == -1){
+ $class ="red";
+ }else if( isset($coveredLines[$linenum]) && $coveredLines[$linenum] == -2){
+ $class ="orange";
+ }
+ $html .= '- ' . htmlspecialchars($line) . '
' . "\n";
+ }
+ $html .='
';
+ echo $html;
+ }
+
+ public function showSummary()
+ {
+ if(isset($_GET["order"])){
+ $this->sortBy = $_GET["order"];
+ }
+ $totallines = 0;
+ $totalcovered = 0;
+ $totalmaybe = 0;
+ $totalnotcovered = 0;
+
+ $coveredArray = array();
+ foreach ($this->coverage as $file => $lines) {
+ $pos = strpos($file, $this->path);
+ if($pos === false && $pos !== 0){
+ continue;
+ }
+
+ $class = str_replace(DIRECTORY_SEPARATOR, '_', substr($file, strlen($this->path), -4));
+ $class = str_replace($this->path, Doctrine::getPath(), $class);
+ if (strpos($class, '_Interface')) {
+ continue;
+ }
+
+ if(!class_exists($class)){
+ continue;
+ }
+
+ $total = count($lines) -1; //we have to remove one since it always reports the last line as a hit
+ $covered = 0;
+ $maybe = 0;
+ $notcovered = 0;
+ foreach($lines as $result){
+ switch($result){
+ case "1":
+ $covered++;
+ break;
+ case "-1":
+ $notcovered++;
+ break;
+ case "-2":
+ $maybe++;
+ break;
+ }
+ }
+ $covered--; //again we have to remove that last line.
+ $totallines += $total;
+ $totalcovered += $covered;
+ $totalnotcovered += $notcovered;
+ $totalmaybe += $maybe;
+
+ if ($total === 0) {
+ $total = 1;
+ }
+ $percentage = round((($covered + $maybe) / $total) * 100, 2);
+ $coveredArray[$class] = array("covered" => $covered, "maybe" => $maybe, "notcovered"=>$notcovered, "total" => $total, "percentage" => $percentage);
+ }
- $total = count($lines) -1; //we have to remove one since it always reports the last line as a hit
- $covered = 0;
- $maybe = 0;
- $notcovered = 0;
- foreach($lines as $result){
- switch($result){
- case "1":
- $covered++;
- break;
- case "-1":
- $notcovered++;
- break;
- case "-2":
- $maybe++;
- break;
+ //lets sort it
+ uasort($coveredArray, array($this,"sortArray"));
+ if(isset($_GET["desc"]) && $_GET["desc"] == "true"){
+ $coveredArray = array_reverse($coveredArray, true);
+ }
+ echo "" . TOTAL . " | " . round((($totalcovered + $totalmaybe) / $totallines) * 100, 2) . " % | $totallines | $totalcovered | $totalmaybe | $totaldead | |
";
+ foreach($coveredArray as $class => $info){
+ $fileName = str_replace("_", "/", $class) . ".php";
+ echo "" . $class . " | " . $info["percentage"] . " % | " . $info["total"] . " | " . $info["covered"] . " | " . $info["maybe"] . " | " . $info["notcovered"]. " | coverage |
";
}
}
- $covered--; //again we have to remove that last line.
- $totallines += $total;
- $totalcovered += $covered;
- $totalnotcovered += $notcovered;
- $totalmaybe += $maybe;
- if ($total === 0) {
- $total = 1;
- }
- $percentage = round((($covered + $maybe) / $total) * 100, 2);
- $coveredArray[$class] = array("covered" => $covered, "maybe" => $maybe, "notcovered"=>$notcovered, "total" => $total, "percentage" => $percentage);
-}
-
-
-//lets sort it
-uasort($coveredArray, "sortArray");
-if(isset($_GET["desc"]) && $_GET["desc"] == "true"){
- $coveredArray = array_reverse($coveredArray, true);
- }
-
-
-?>
-Coverage report for Doctrine
-Default mode shows results sorted by perentage. This can be changed with order = covered|total|maybe|notcovered|percentage and desc=true GET variables
-";
-echo " | Percentage | Total | Covered | Maybe | Not Covered | |
";
-print "" . TOTAL . " | " . round((($totalcovered + $totalmaybe) / $totallines) * 100, 2) . " % | $totallines | $totalcovered | $totalmaybe | $totaldead | |
";
-foreach($coveredArray as $class => $info){
- print "" . $class . " | " . $info["percentage"] . " % | " . $info["total"] . " | " . $info["covered"] . " | " . $info["maybe"] . " | " . $info["notcovered"]. " | " . printLink($class) . " |
";
-}
-print "";
-
-function sortArray($a, $b){
- global $key;
- if ($a[$key] == $b[$key]) {
- return 0;
- }
- return ($a[$key] < $b[$key]) ? -1 : 1;
-}
-
-function printLink($className){
- global $path;
- $className = str_replace("_", "/", $className) . ".php";
- return 'coverage';
- }
-
-function countCovered($value, $key){
- global $covered;
- if($value >= 1){
- $covered++;
+ public function sortArray($a, $b)
+ {
+ if ($a[$this->sortBy] == $b[$this->sortBy]) {
+ return 0;
+ }
+ return ($a[$this->sortBy] < $b[$this->sortBy]) ? -1 : 1;
}
}
+
diff --git a/tests/coverage.php b/tests/coverage.php
deleted file mode 100644
index 46a83c7e9..000000000
--- a/tests/coverage.php
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-$result = unserialize(file_get_contents("coverage.txt"));
-
-function getCoverageReport($file){
- global $result;
- $coverage = $result["coverage"];
- $path = $result["path"];
- $html = '';
- if(!isset($coverage[$file])){
- $html .= 'No coverage for this file
';
- return $html;
- }
- $coveredLines = $coverage[$file];
- $fileArray = file(str_replace($path, Doctrine::getPath() . "/", $file));
- $html .= '' . "\n";
- foreach($fileArray as $num => $line){
- $linenum = $num+1;
- $html .= '- ' . $linenum . '
' . "\n";
- $class ="normal";
- if(isset($coveredLines[$linenum]) && $coveredLines[$linenum] == 1){
- $class = "covered";
- }else if(isset($coveredLines[$linenum]) && $coveredLines[$linenum] == -1){
- $class ="red";
- }else if(isset($coveredLines[$linenum]) && $coveredLines[$linenum] == -2){
- $class ="orange";
- }
- $html .= '- ' . htmlspecialchars($line) . '
' . "\n";
- }
- $html .='
';
- return $html;
-}
-
-if(isset($_GET["file"])){
- $file = $_GET["file"];
- echo 'Back to filelist';
- echo 'Back to coverage report';
- echo 'Coverage for ' . $file . '
';
- echo getCoverageReport($file);
-
- }else{
-echo "";
-$it = new RecursiveDirectoryIterator(Doctrine::getPath());
-foreach(new RecursiveIteratorIterator($it) as $file){
- if(strpos($file->getPathname(), ".svn")){
- continue;
- }
- echo '- ' . $file->getPathname() . '
';
-}
-}
-?>
-
-