]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19579 code coverage - fix report paths and totals. Yay, I'm back!
authorstronk7 <stronk7>
Thu, 25 Jun 2009 21:01:25 +0000 (21:01 +0000)
committerstronk7 <stronk7>
Thu, 25 Jun 2009 21:01:25 +0000 (21:01 +0000)
lib/simpletestcoveragelib.php

index 7d034e0319e2abb79ec2c06fb12f25ddd768cc6a..a3c3f689f2da565b462c801f5bf4e84b18df5f31 100644 (file)
@@ -332,6 +332,61 @@ class moodle_coverage_reporter extends HtmlCoverageReporter {
         global $CFG;
         parent::__construct($heading, '', $CFG->dataroot . '/codecoverage/' . $dir);
     }
+
+    /**
+     * Writes one row in the index.html table to display filename
+     * and coverage recording.
+     *
+     * Overrided to transform names and links to shorter format
+     *
+     * @param $fileLink link to html details file.
+     * @param $realFile path to real PHP file.
+     * @param $fileCoverage Coverage recording for that file.
+     * @return string HTML code for a single row.
+     * @access protected
+     */
+    protected function writeIndexFileTableRow($fileLink, $realFile, $fileCoverage) {
+
+        global $CFG;
+
+        $fileLink = str_replace($CFG->dirroot, '', $fileLink);
+        $realFile = str_replace($CFG->dirroot, '', $realFile);
+
+        return parent::writeIndexFileTableRow($fileLink, $realFile, $fileCoverage);;
+    }
+
+    /**
+     * Mark a source code file based on the coverage data gathered
+     *
+     * Overrided to transform names and links to shorter format
+     *
+     * @param $phpFile Name of the actual source file
+     * @param $fileLink Link to the html mark-up file for the $phpFile
+     * @param &$coverageLines Coverage recording for $phpFile
+     * @return boolean FALSE on failure
+     * @access protected
+     */
+    protected function markFile($phpFile, $fileLink, &$coverageLines) {
+        global $CFG;
+
+        $fileLink = str_replace($CFG->dirroot, '', $fileLink);
+
+        return parent::markFile($phpFile, $fileLink, $coverageLines);
+    }
+
+
+    /**
+     * Update the grand totals
+     *
+     * Overrided to avoid the call to recordFileCoverageInfo()
+     * because it has been already executed by writeIndexFile() and
+     * cause files to be duplicated in the fileCoverage property
+     */
+    protected function updateGrandTotals(&$coverageCounts) {
+        $this->grandTotalLines += $coverageCounts['total'];
+        $this->grandTotalCoveredLines += $coverageCounts['covered'];
+        $this->grandTotalUncoveredLines += $coverageCounts['uncovered'];
+    }
 }