diff --git a/src/Gitonomy/Git/Admin.php b/src/Gitonomy/Git/Admin.php index c532ba3..ba5cd17 100644 --- a/src/Gitonomy/Git/Admin.php +++ b/src/Gitonomy/Git/Admin.php @@ -129,7 +129,7 @@ public static function mirrorTo($path, $url, array $options = array()) * * @return Repository */ - private static function cloneRepository($path, $url, array $args = array(), array $options = array()) + public static function cloneRepository($path, $url, array $args = array(), array $options = array()) { $process = static::getProcess('clone', array_merge(array('-q'), $args, array($url, $path)), $options); diff --git a/tests/Gitonomy/Git/Tests/AdminTest.php b/tests/Gitonomy/Git/Tests/AdminTest.php index d344c38..2e32a3e 100644 --- a/tests/Gitonomy/Git/Tests/AdminTest.php +++ b/tests/Gitonomy/Git/Tests/AdminTest.php @@ -158,4 +158,21 @@ public function testExistingFile() Admin::init($file, true, self::getOptions()); } + + public function testCloneRepository() + { + $newDir = self::createTempDir(); + $args = array(); + + $new = Admin::cloneRepository($newDir, self::REPOSITORY_URL, $args, self::getOptions()); + self::registerDeletion($new); + + $newRefs = array_keys($new->getReferences()->getAll()); + + $this->assertTrue(in_array('refs/heads/master', $newRefs)); + $this->assertTrue(in_array('refs/tags/0.1', $newRefs)); + + $this->assertEquals($newDir.'/.git', $new->getGitDir()); + $this->assertEquals($newDir, $new->getWorkingDir()); + } }