diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-05-01 22:29:51 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-05-01 22:29:51 -0400 |
commit | c2d15e6c3bd8a29bae89d184a999ddac15fcb807 (patch) | |
tree | 96cbbfa98f131d830fbfd154f82e37383bb37bd8 /library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php | |
parent | b1ae4d776c7c093c7f3ff6905e1a5302fbd5e3f6 (diff) | |
download | volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.gz volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.bz2 volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.zip |
New plugin repo is cloned to /store/pluginrepos/REPONAME for analysis
Diffstat (limited to 'library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php')
-rw-r--r-- | library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php b/library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php new file mode 100644 index 000000000..4deeea367 --- /dev/null +++ b/library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php @@ -0,0 +1,106 @@ +<?php + +use PHPGit\Git; +use Symfony\Component\Filesystem\Filesystem; + +require_once __DIR__ . '/../BaseTestCase.php'; + +class BranchCommandTest extends BaseTestCase +{ + + public function setUp() + { + parent::setUp(); + + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + + $filesystem->dumpFile($this->directory . '/test.txt', ''); + $git->add('test.txt'); + $git->commit('Initial commit'); + } + + public function testBranch() + { + $git = new Git(); + $git->setRepository($this->directory); + + $branches = $git->branch(); + + $this->assertCount(1, $branches); + $this->assertEquals('master', $branches['master']['name']); + $this->assertTrue($branches['master']['current']); + $this->assertEquals('Initial commit', $branches['master']['title']); + } + + public function testAllBranch() + { + $git = new Git(); + $git->clone('file://' . realpath($this->directory), $this->directory.'2'); + $git->setRepository($this->directory.'2'); + + $branches = $git->branch(array('remotes' => true)); + $this->assertArrayHasKey('origin/master', $branches); + + $branches = $git->branch(array('all' => true)); + $this->assertArrayHasKey('master', $branches); + $this->assertArrayHasKey('remotes/origin/master', $branches); + + $filesystem = new Filesystem(); + $filesystem->remove($this->directory.'2'); + } + + public function testBranchCreate() + { + $git = new Git(); + $git->setRepository($this->directory); + + $git->branch->create('1.0'); + $branches = $git->branch(); + $this->assertCount(2, $branches); + + $git->branch->create('1.0-fix', '1.0', array('force' => true)); + $branches = $git->branch(); + $this->assertCount(3, $branches); + $this->assertArrayHasKey('1.0', $branches); + $this->assertArrayHasKey('1.0-fix', $branches); + } + + public function testBranchMove() + { + $git = new Git(); + $git->setRepository($this->directory); + $git->branch->create('1.0'); + $git->branch->move('1.0', '1.0.x'); + $branches = $git->branch(); + $this->assertCount(2, $branches); + $this->assertArrayHasKey('1.0.x', $branches); + + $git->branch->move('1.0.x', '2.x', array('force' => true)); + $branches = $git->branch(); + $this->assertCount(2, $branches); + $this->assertArrayHasKey('2.x', $branches); + } + + public function testBranchDelete() + { + $git = new Git(); + $git->setRepository($this->directory); + $git->branch->create('1.0'); + $git->branch->create('2.0'); + $branches = $git->branch(); + $this->assertCount(3, $branches); + + $git->branch->delete('1.0'); + $branches = $git->branch(); + $this->assertCount(2, $branches); + + $git->branch->delete('2.0', array('force' => true)); + $branches = $git->branch(); + $this->assertCount(1, $branches); + } + +}
\ No newline at end of file |