/** * Creates a changeset instance for the given source file. * * @param PHP_ChangeCoverage_Source_File $file * * @return PHP_ChangeCoverage_ChangeSet */ public function create(PHP_ChangeCoverage_Source_File $file) { if (is_object($vcs = $this->createVcsFile($file->getPath()))) { return new PHP_ChangeCoverage_ChangeSet_VersionControl($vcs, $file); } return new PHP_ChangeCoverage_ChangeSet_FileSystem($file); }
/** * 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]); } } }
/** * 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); }
/** * 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()); }
/** * 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()); }
/** * 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(); } }