Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
bugfix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
holyshared committed Sep 15, 2014
1 parent 4481bf9 commit f969476
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions spec/reporter/LcovReporterSpec.php
Expand Up @@ -64,6 +64,7 @@

$output .= "SF:" . $this->source2 . PHP_EOL;
$output .= "DA:10,1" . PHP_EOL;
$output .= "DA:15,0" . PHP_EOL;
$output .= "end_of_record" . PHP_EOL;

$this->output = $output;
Expand Down
18 changes: 10 additions & 8 deletions src/reporter/LcovReporter.php
Expand Up @@ -80,10 +80,10 @@ private function writeFileResult(File $file)
{
$this->writeFileHeader($file);

$executedLines = $this->getExecutedLinesFromFile($file);
$targetLines = $this->getTargetLinesFromFile($file);

foreach ($executedLines as $executedLine) {
$this->writeLineResult($executedLine);
foreach ($targetLines as $targetLine) {
$this->writeLineResult($targetLine);
}

$this->writeFileFooter();
Expand Down Expand Up @@ -113,25 +113,27 @@ private function writeFileFooter()
*/
private function writeLineResult(Line $line)
{
$parts = [

$executedCount = $line->isExecuted() ? 1 : 0;
$recordParts = [
$line->getLineNumber(),
1
$executedCount
];

$record = 'DA:' . implode(',', $parts);
$record = 'DA:' . implode(',', $recordParts);
$this->reportWriter->writeLine($record);
}

/**
* @param File $file
* @return array
*/
private function getExecutedLinesFromFile(File $file)
private function getTargetLinesFromFile(File $file)
{
$lineResults = $file->getLineResults();

$results = $lineResults->selectLines(function(Line $line) {
return $line->isExecuted();
return $line->isExecuted() || $line->isUnused();
})->all();

return $results;
Expand Down

0 comments on commit f969476

Please sign in to comment.