From c2d15e6c3bd8a29bae89d184a999ddac15fcb807 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 1 May 2016 22:29:51 -0400 Subject: New plugin repo is cloned to /store/pluginrepos/REPONAME for analysis --- .../git/test/PHPGit/Command/BranchCommandTest.php | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php (limited to 'library/kzykhys/git/test/PHPGit/Command/BranchCommandTest.php') 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 @@ +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 -- cgit v1.2.3