Пример #1
0
 /**
  * Prepare file link to assert
  *
  * @param string $commitId Commit identifier
  * @param string $filePath Relative file path
  * @param string $mode File view mode
  *
  * @return string
  */
 protected function prepareFileMode($projectId, $commitId, File $file, $mode)
 {
     if ($mode == 'history') {
         return '<a href="/projects/' . $projectId . '/revisions/simple?path=' . $file->getPathname() . '">[history]</a>';
     } else {
         $link = 'commitId=' . $commitId . '&amp;filePath=' . $file->getPathname() . '&amp;mode=' . $mode;
         $containerId = $commitId . md5($file->getPathname());
         return '<a class="js-revision-file revision-file-link" href="#" data-params="' . $link . '" data-container="' . $containerId . '" data-mode="' . $mode . '">[' . $mode . ']</a>';
     }
 }
Пример #2
0
 /**
  * Tests commit variables
  */
 public function testCommitVariables()
 {
     $commit = $this->repository->getCommit($this->variables['diff']);
     $this->assertInstanceOf('DateTime', $commit->getDate());
     /* @var $wrapper GitWrapper */
     $wrapper = $this->repository->getWrapper();
     $this->assertTrue($wrapper->checkIsSha1($commit->getId()));
     $this->assertNotEmpty($commit->contributorName);
     $this->assertNotEmpty($commit->contributorEmail);
     $this->assertNotEmpty($commit->message);
     $this->assertNotEmpty($commit->getParentsId());
     foreach ($commit->getParentsId() as $parentId) {
         $this->assertTrue($wrapper->checkIsSha1($parentId));
     }
     $this->assertNotEmpty($commit->getChangedFiles());
     $this->assertContainsOnly(File::className(), $commit->getChangedFiles());
     $lastFilePath = null;
     $lastFileStatus = null;
     foreach ($commit->getChangedFiles() as $item) {
         $this->assertInstanceOf(File::className(), $item);
         $this->assertInternalType('string', $item->getStatus());
         $this->assertInternalType('string', $item->getPath());
         $this->assertInternalType('string', $item->getPathname());
         $lastFilePath = $item->getPathname();
         $lastFileStatus = $item->getStatus();
     }
     $this->assertEquals($commit->getFileStatus($lastFilePath), $lastFileStatus);
     $lastFile = $commit->getFileByPath($lastFilePath);
     $this->assertInstanceOf(File::className(), $lastFile);
     $this->assertEquals($lastFilePath, $lastFile->getPathname());
     $this->assertEquals($lastFileStatus, $lastFile->getStatus());
     return $commit;
 }
Пример #3
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!$this->project instanceof Project) {
         throw new InvalidParamException('Project variable must be an instance of ' . Project::className());
     }
     if (!$this->repository instanceof BaseRepository) {
         throw new InvalidParamException('Repository variable must be an instance of ' . BaseRepository::className());
     }
     if (!$this->commit instanceof BaseCommit) {
         throw new InvalidParamException('Commit variable must be an instance of ' . BaseCommit::className());
     }
     if (!$this->file instanceof File) {
         throw new InvalidParamException('File variable must be an instance of ' . File::className());
     }
     $this->id = $this->commit->getId() . md5($this->file->getPathname());
 }
Пример #4
0
 /**
  * Tests history getter for sepcified path
  */
 public function testPathHistory()
 {
     $history = $this->repository->getHistory(2, 0, $this->variables['pathHistory']);
     $this->assertNotEmpty($history);
     $this->assertContainsOnlyInstancesOf(Commit::className(), $history);
     $this->assertCount(2, $history);
     foreach ($history as $commit) {
         /* @var $commit Commit */
         $commit = $this->repository->getCommit($commit->getId());
         $this->assertNotEmpty($commit->getChangedFiles());
         $hasCurrentFile = false;
         foreach ($commit->getChangedFiles() as $file) {
             /* @var $file File */
             $this->assertInstanceOf(File::className(), $file);
             if ($this->variables['pathHistory'] === $file->getPathname()) {
                 $hasCurrentFile = true;
             }
         }
         $this->assertTrue($hasCurrentFile);
     }
     return $history;
 }