public function testBranchExists() { $commandExecutor = new MockCommandExecutor(new MockCommandBuilder()); $vcs = new GitVcs($commandExecutor); $meta = $vcs->getMeta(); $this->assertInstanceOf('\\ptlis\\Vcs\\Interfaces\\MetaInterface', $meta); }
public function testBranchExists() { $result = array(new ShellResult(0, '', ''), new ShellResult(0, '', ''), new ShellResult(0, '', '')); $mockExecutor = new MockCommandExecutor(new MockCommandBuilder($result, '/usr/bin/git')); $vcs = new GitVcs($mockExecutor); $vcs->update(); $this->assertEquals(array(array('reset', '--hard'), array('fetch'), array('rebase')), $mockExecutor->getArguments()); }
public function testBranchDoesntExist() { $this->setExpectedException('\\RuntimeException', 'Branch named "feat-new-badness" not found.'); $results = array(new ShellResult(0, '', '')); $commandExecutor = new MockCommandExecutor(new MockCommandBuilder($results, '/usr/bin/git')); $vcs = new GitVcs($commandExecutor); $vcs->changeBranch('feat-new-badness'); }
public function testNotFound() { $this->setExpectedException('\\RuntimeException', 'Revision "bob" not found.'); $results = array(new ShellResult(0, 'fatal: ambiguous argument \'bob\': unknown revision or path not in the working tree.' . PHP_EOL . 'Use \'--\' to separate paths from revisions, like this:' . PHP_EOL . '\'git <command> [<revision>...] -- [<file>...]\'' . PHP_EOL, '')); $mockExecutor = new MockCommandExecutor(new MockCommandBuilder($results, '/usr/bin/git')); $vcs = new GitVcs($mockExecutor); $vcs->checkoutRevision('bob'); }
public function testNotRequired() { $result = array(new ShellResult(0, 'master' . PHP_EOL, '')); $mockExecutor = new MockCommandExecutor(new MockCommandBuilder($result, '/usr/bin/git')); $vcs = new GitVcs($mockExecutor); $vcs->resetRevision(); $this->assertEquals(array(), $mockExecutor->getArguments()); }