Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Merge [882].

  • Loading branch information...
commit 129113e3091e4b7d6b10130cd11edaff475fe8b8 1 parent e7279ed
@sebastianbergmann authored
View
24 PHPUnit/Util/Log/CodeCoverage/Database.php
@@ -49,6 +49,7 @@
require_once 'PHPUnit/Util/CodeCoverage.php';
require_once 'PHPUnit/Util/Filesystem.php';
require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/SourceFile.php';
PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
@@ -101,10 +102,14 @@ public function storeCodeCoverage(PHPUnit_Framework_TestResult $result, $revisio
$this->dbh->beginTransaction();
foreach ($files as $file) {
- $filename = str_replace($commonPath, '', $file);
- $fileId = FALSE;
- $lines = file($file);
- $numLines = count($lines);
+ $sourceFile = new PHPUnit_Util_SourceFile($file);
+ $filename = str_replace($commonPath, '', $file);
+ $fileId = FALSE;
+ $lines = $sourceFile->getLines();
+ $loc = $sourceFile->getLoc();
+ $cloc = $sourceFile->getCloc();
+ $ncloc = $sourceFile->getNcloc();
+ $hash = md5_file($file);
$stmt = $this->dbh->prepare(
'SELECT code_file_id
@@ -124,17 +129,18 @@ public function storeCodeCoverage(PHPUnit_Framework_TestResult $result, $revisio
unset($stmt);
if ($fileId == 0) {
- $hash = md5_file($file);
-
$stmt = $this->dbh->prepare(
'INSERT INTO code_file
- (code_file_name, code_file_md5, revision)
- VALUES(:filename, :hash, :revision);'
+ (code_file_name, code_file_md5, revision, loc, cloc, ncloc)
+ VALUES(:filename, :hash, :revision, :loc, :cloc, :ncloc);'
);
$stmt->bindParam(':filename', $filename, PDO::PARAM_STR);
$stmt->bindParam(':hash', $hash, PDO::PARAM_STR);
$stmt->bindParam(':revision', $revision, PDO::PARAM_INT);
+ $stmt->bindParam(':loc', $loc, PDO::PARAM_INT);
+ $stmt->bindParam(':cloc', $cloc, PDO::PARAM_INT);
+ $stmt->bindParam(':ncloc', $ncloc, PDO::PARAM_INT);
$stmt->execute();
$fileId = $this->dbh->lastInsertId();
@@ -227,7 +233,7 @@ public function storeCodeCoverage(PHPUnit_Framework_TestResult $result, $revisio
VALUES(:testId, :lineId);'
);
- for ($lineNumber = 1; $lineNumber <= $numLines; $lineNumber++) {
+ for ($lineNumber = 1; $lineNumber <= $loc; $lineNumber++) {
$coveringTests = PHPUnit_Util_CodeCoverage::getCoveringTests(
$codeCoverage, $file, $lineNumber
);
View
5 PHPUnit/Util/Log/Database/MySQL.sql
@@ -67,7 +67,10 @@ CREATE TABLE IF NOT EXISTS code_file(
code_file_id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
code_file_name CHAR(255),
code_file_md5 CHAR(32),
- revision INTEGER UNSIGNED NOT NULL
+ revision INTEGER UNSIGNED NOT NULL,
+ loc INTEGER UNSIGNED NOT NULL,
+ cloc INTEGER UNSIGNED NOT NULL,
+ ncloc INTEGER UNSIGNED NOT NULL
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS code_class(
View
5 PHPUnit/Util/Log/Database/SQLite3.sql
@@ -67,7 +67,10 @@ CREATE TABLE IF NOT EXISTS code_file(
code_file_id INTEGER PRIMARY KEY AUTOINCREMENT,
code_file_name TEXT,
code_file_md5 TEXT,
- revision INTEGER
+ revision INTEGER,
+ loc INTEGER,
+ cloc INTEGER,
+ ncloc INTEGER
);
CREATE TABLE IF NOT EXISTS code_class(
Please sign in to comment.
Something went wrong with that request. Please try again.