Пример #1
0
 /**
  * @test
  */
 public function checkoutChecksOutValidCommit()
 {
     $this->skipTestIfGitCommandForTestingDoesNotExist();
     $this->proxy->init()->execute();
     $this->proxy->remote()->add()->setName('origin')->setUrl(sprintf("file://%s", $this->remoteRepositoryRootPath))->execute();
     file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film01.txt")), "Dr. Strangelove Or How I Stopped Worrying And Love The Bomb");
     file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt")), "2001 - A Space Odyssey");
     $this->proxy->add()->setPath(".")->execute();
     $this->proxy->commit()->setMessage("[TASK] Initial commit")->execute();
     $expectedCommitHash = $this->proxy->log()->setMaxCount(1)->setFormat("%H")->execute()->getRawResult();
     $this->assertRegExp('/[a-z0-9]{40}/', $expectedCommitHash);
     unlink(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt")));
     file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film01.txt")), "Lolita");
     file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film03.txt")), "A Clockwork Orange");
     $this->proxy->add()->setPath(".")->execute();
     $this->proxy->commit()->setMessage("[CHG] Change film texts")->execute();
     $this->assertFileExists(Files::concatenatePaths(array($this->repositoryRootPath, "film01.txt")));
     $this->assertFileNotExists(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt")));
     $this->assertFileExists(Files::concatenatePaths(array($this->repositoryRootPath, "film03.txt")));
     file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt")), "Paths Of Glory");
     $this->proxy->checkout()->setForce(true)->setQuiet(true)->setCommit($expectedCommitHash)->execute();
     $actualCommitHash = $this->proxy->log()->setMaxCount(1)->setFormat("%H")->execute()->getRawResult();
     $this->assertRegExp('/[a-z0-9]{40}/', $actualCommitHash);
     $this->assertSame($expectedCommitHash, $actualCommitHash);
     $this->assertFileExists(Files::concatenatePaths(array($this->repositoryRootPath, "film01.txt")));
     $this->assertStringEqualsFile(Files::concatenatePaths(array($this->repositoryRootPath, "film01.txt")), "Dr. Strangelove Or How I Stopped Worrying And Love The Bomb");
     $this->assertFileExists(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt")));
     $this->assertStringEqualsFile(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt")), "2001 - A Space Odyssey");
     $this->assertFileNotExists(Files::concatenatePaths(array($this->repositoryRootPath, "film03.txt")));
 }
Пример #2
0
 /**
  * @test
  */
 public function commandRendersValidCommand()
 {
     $this->prepareShellCommandExpectations();
     $this->proxy->cloneRepository()->setRepository('file:///path/to/a/repository/of/chocolate.git')->setDirectory('/path/to/checked/out/chocolate/')->execute();
     $this->proxy->cloneRepository()->setRepository('file:///path/to/a/repository/of/chocolate.git')->setDirectory('/path/to/checked/out/chocolate/')->setDepth(1)->setBranch('YummyTag')->execute();
     $this->proxy->checkout()->setForce(true)->setQuiet(true)->setCommit('c0ca3ae2f34ef4dc024093f92547b43a4d9bd58a')->execute();
     $this->proxy->log()->setMaxCount(10)->execute();
     $this->proxy->log()->setFormat('%H')->execute();
     $this->proxy->config()->setGlobal(true)->setUserName('Bud Spencer')->execute();
     $this->proxy->config()->setGlobal(true)->setEmail('*****@*****.**')->execute();
     $this->proxy->remote()->remove()->setName('origin')->execute();
     $this->proxy->remote()->add()->setName('origin')->setUrl('file:///tmp/punktde.git')->execute();
     $this->proxy->init()->setBare(true)->setShared(true)->execute();
     $this->proxy->push()->setTags()->setRemote('origin')->setRefspec('master')->execute();
     $this->proxy->tag()->setName('v1.2.3')->setSign(true)->setAnnotate(true)->setMessage('Release')->execute();
     $this->proxy->commit()->setAllowEmpty(true)->setMessage('This is a very empty commit!')->execute();
     $this->proxy->commit()->setMessage('This is a very cool message!')->execute();
     $this->proxy->add()->setPath('.')->setAll(true)->execute();
     $this->proxy->status()->setShort(true)->execute();
     $this->proxy->log()->setNameOnly(true)->execute();
 }