/**
  * This method calculates the changed lines within the specified time range
  * and the given version for the context file and flags all changed lines
  * as changed.
  *
  * @param string|integer $version The vcs version to check.
  *
  * @return void
  */
 protected function calculateChangedLinesForVersion($version)
 {
     $blame = $this->vcs->blame($version);
     foreach ($this->file->getLines() as $line) {
         if (isset($blame[$line->getNumber() - 1])) {
             $this->flagChangedLines($line, $blame[$line->getNumber() - 1]);
         }
     }
 }
Пример #2
0
 /**
  * This method creates an array with coverage data similar to that arrays
  * which xdebug's coverage code generates.
  *
  * This method sets an internal execution flag to <b>true</b> when there is
  * more coverage information available than the current array contains.
  *
  * @return array(integer=>integer)
  */
 protected function createXdebugCoverageArray()
 {
     $this->stopExecution = true;
     $xdebug = array();
     foreach ($this->file->getLines() as $line) {
         if ($line->hasChanged($line)) {
             if ($line->getCount() === 0) {
                 $xdebug[$line->getNumber()] = -1;
             } else {
                 if ($line->decrementCount() > 0) {
                     $this->stopExecution = false;
                 }
                 $xdebug[$line->getNumber()] = 1;
             }
         } else {
             $xdebug[$line->getNumber()] = $this->unmodifiedLineStatus;
         }
     }
     return array($this->file->getPath() => $xdebug);
 }
 /**
  * testCalculateNotFlagsLinesChangedWhenFilemtimeIsNotInDateRange
  *
  * @return void
  * @covers PHP_ChangeCoverage_ChangeSet_FileSystem
  * @group changeset
  * @group unittest
  */
 public function testCalculateNotFlagsLinesChangedWhenFilemtimeIsNotInDateRange()
 {
     $file = new PHP_ChangeCoverage_Source_File(__FILE__, array(new PHP_ChangeCoverage_Source_Line(__LINE__, 1)));
     $changeSet = new PHP_ChangeCoverage_ChangeSet_FileSystem($file);
     $changeSet->setStartDate(filemtime(__FILE__) + 1);
     $changeSet->calculate();
     self::assertFalse($file->getLines()->current()->hasChanged());
 }
 /**
  * testGetLinesReturnsIteratorInstance
  *
  * @return void
  * @covers PHP_ChangeCoverage_Source_File
  * @group source
  * @group unittest
  */
 public function testGetLinesReturnsIteratorInstance()
 {
     $file = new PHP_ChangeCoverage_Source_File(__FILE__, array());
     self::assertType('Iterator', $file->getLines());
 }
 /**
  * This method updates the changed status of all lines in the context source
  * file to <b>true</b>.
  *
  * @return void
  */
 protected function updateChangedStatus()
 {
     foreach ($this->file->getLines() as $line) {
         $line->setChanged();
     }
 }