Beispiel #1
0
 /**
  * clone url
  */
 public function testPush()
 {
     $pc = PushCommand::getInstance();
     $this->assertEquals("push 'origin' 'master'", $pc->push());
     $this->assertEquals("push 'github' 'master'", $pc->push('github'));
     $this->assertEquals("push 'github' 'develop'", $pc->push('github', 'develop'));
     $this->getRepository()->addRemote('test-remote', 'git@github.com:matteosister/GitElephant.git');
     $remote = m::mock('GitElephant\\Objects\\Remote')->shouldReceive('getName')->andReturn('test-remote')->getMock();
     $this->assertEquals("push 'test-remote' 'develop'", $pc->push($remote, 'develop'));
     $branch = Branch::create($this->getRepository(), 'test-branch');
     $this->assertEquals("push 'test-remote' 'test-branch'", $pc->push($remote, $branch));
 }
 /**
  * fetch test
  */
 public function testFetch()
 {
     $fc = FetchCommand::getInstance();
     $this->assertEquals("fetch", $fc->fetch());
     $this->assertEquals("fetch 'github'", $fc->fetch('github'));
     $this->assertEquals("fetch 'github' 'develop'", $fc->fetch('github', 'develop'));
     $this->getRepository()->addRemote('test-remote', 'git@github.com:matteosister/GitElephant.git');
     $remote = m::mock('GitElephant\\Objects\\Remote')->shouldReceive('getName')->andReturn('test-remote')->getMock();
     $this->assertEquals("fetch 'test-remote' 'develop'", $fc->fetch($remote, 'develop'));
     $branch = Branch::create($this->getRepository(), 'test-branch');
     $this->assertEquals("fetch 'test-remote' 'test-branch'", $fc->fetch($remote, $branch));
     $this->assertEquals("fetch '--tags' 'test-remote' 'test-branch'", $fc->fetch($remote, $branch, array('--tags')));
 }
Beispiel #3
0
 /**
  * testTagFromStartPoint
  */
 public function testTagFromStartPoint()
 {
     $this->getRepository()->init();
     $this->addFile('foo');
     $this->repository->commit('commit1', true);
     Tag::create($this->repository, 'tag1', $this->repository->getCommit());
     $tag = new Tag($this->repository, 'tag1');
     $this->assertInstanceOf('GitElephant\\Objects\\Tag', $tag);
     $this->assertEquals($tag->getSha(), $this->repository->getCommit()->getSha());
     $branch = Branch::create($this->repository, 'test-branch');
     Tag::create($this->repository, 'tag2', $branch);
     $tag = new Tag($this->repository, 'tag2');
     $this->assertEquals($tag->getSha(), $branch->getSha());
 }
Beispiel #4
0
 /**
  * parents created by log
  */
 public function testParents()
 {
     $log = $this->getRepository()->getLog();
     $lastCommit = $this->repository->getCommit();
     $lastLogCommit = $log[0];
     $this->assertEquals($lastCommit->getParents(), $lastLogCommit->getParents());
     Branch::create($this->repository, 'new-branch');
     $this->getRepository()->checkout('new-branch');
     $this->addFile('another file');
     $this->repository->commit('another commit', true);
     $lastCommitOtherBranch = $this->getRepository()->getCommit();
     $this->getRepository()->checkout('master');
     $this->addFile('another file on master');
     $this->getRepository()->commit('new commit on master', true);
     $lastCommitOnMaster = $this->getRepository()->getCommit();
     $this->getRepository()->merge($this->getRepository()->getBranch('new-branch'));
     $log = $this->getRepository()->getLog();
     $lastLogCommit = $log[0];
     $this->assertContains($lastCommitOnMaster->getSha(), $lastLogCommit->getParents());
     $this->assertContains($lastCommitOtherBranch->getSha(), $lastLogCommit->getParents());
 }
Beispiel #5
0
 /**
  * Create a new branch
  *
  * @param string $name       the new branch name
  * @param null   $startPoint the reference to create the branch from
  *
  * @throws \RuntimeException
  * @throws \Symfony\Component\Process\Exception\RuntimeException
  * @return Repository
  */
 public function createBranch($name, $startPoint = null)
 {
     Branch::create($this, $name, $startPoint);
     return $this;
 }
Beispiel #6
0
 /**
  * testCreate
  */
 public function testCreate()
 {
     $this->getRepository()->init();
     $this->addFile('test');
     $this->repository->commit('test', true);
     $this->assertCount(1, $this->repository->getBranches(true));
     Branch::create($this->repository, 'test-branch');
     $this->assertCount(2, $this->repository->getBranches(true));
     Branch::create($this->repository, 'test-branch2', 'test-branch');
     $this->assertCount(3, $this->repository->getBranches(true));
 }