composer update
This commit is contained in:
149
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/AbstractTest.php
vendored
Normal file
149
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/AbstractTest.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Admin;
|
||||
use Gitonomy\Git\Repository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractTest extends TestCase
|
||||
{
|
||||
const REPOSITORY_URL = 'http://github.com/gitonomy/foobar.git';
|
||||
|
||||
const LONGFILE_COMMIT = '4f17752acc9b7c54ba679291bf24cb7d354f0f4f';
|
||||
const BEFORE_LONGFILE_COMMIT = 'e0ec50e2af75fa35485513f60b2e658e245227e9';
|
||||
const LONGMESSAGE_COMMIT = '3febd664b6886344a9b32d70657687ea4b1b4fab';
|
||||
const INITIAL_COMMIT = '74acd054c8ec873ae6be044041d3a85a4f890ba5';
|
||||
const MERGE_COMMIT = '2f5b9d0a4e6e7173d7816e417805709c708674f8';
|
||||
const ENCODING_COMMIT = '779420b9b936f18a0b6579e1499a85b14270802e';
|
||||
const SIGNED_COMMIT = 'e1a83f16ed61ae3807e5652c7ef894692c813513';
|
||||
|
||||
/**
|
||||
* Local clone of remote URL. Avoids network call on each test.
|
||||
*/
|
||||
private static $localRepository;
|
||||
|
||||
/**
|
||||
* Creates an empty git repository and returns instance.
|
||||
*
|
||||
* @return Repository
|
||||
*/
|
||||
public static function createEmptyRepository($bare = true)
|
||||
{
|
||||
$dir = self::createTempDir();
|
||||
$repository = Admin::init($dir, $bare, self::getOptions());
|
||||
self::registerDeletion($repository);
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used as data provider to get bare/not-bare repositories.
|
||||
*/
|
||||
public static function provideFoobar()
|
||||
{
|
||||
return array(
|
||||
array(self::createFoobarRepository()),
|
||||
array(self::createFoobarRepository(false)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used as data provider to get bare/not-bare repositories.
|
||||
*/
|
||||
public static function provideEmpty()
|
||||
{
|
||||
return array(
|
||||
array(self::createEmptyRepository()),
|
||||
array(self::createEmptyRepository(false)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a fixture test repository.
|
||||
*
|
||||
* @return Repository
|
||||
*/
|
||||
public static function createFoobarRepository($bare = true)
|
||||
{
|
||||
if (null === self::$localRepository) {
|
||||
self::$localRepository = Admin::cloneTo(self::createTempDir(), self::REPOSITORY_URL, $bare, self::getOptions());
|
||||
}
|
||||
|
||||
$repository = self::$localRepository->cloneTo(self::createTempDir(), $bare, self::getOptions());
|
||||
self::registerDeletion($repository);
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
||||
public static function registerDeletion(Repository $repository)
|
||||
{
|
||||
register_shutdown_function(function () use ($repository) {
|
||||
if ($repository->getWorkingDir()) {
|
||||
$dir = $repository->getWorkingDir();
|
||||
} else {
|
||||
$dir = $repository->getGitDir();
|
||||
}
|
||||
AbstractTest::deleteDir($dir);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Created an empty directory and return path to it.
|
||||
*
|
||||
* @return string a fullpath
|
||||
*/
|
||||
public static function createTempDir()
|
||||
{
|
||||
$tmpDir = tempnam(sys_get_temp_dir(), 'gitlib_');
|
||||
unlink($tmpDir);
|
||||
mkdir($tmpDir);
|
||||
|
||||
return $tmpDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a directory recursively.
|
||||
*
|
||||
* @param string $dir directory to delete
|
||||
*/
|
||||
public static function deleteDir($dir)
|
||||
{
|
||||
$iterator = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS);
|
||||
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($iterator as $file) {
|
||||
if (!is_link($file)) {
|
||||
chmod($file, 0777);
|
||||
}
|
||||
if (is_dir($file)) {
|
||||
rmdir($file);
|
||||
} else {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
chmod($dir, 0777);
|
||||
rmdir($dir);
|
||||
}
|
||||
|
||||
protected static function getOptions()
|
||||
{
|
||||
$command = isset($_SERVER['GIT_COMMAND']) ? $_SERVER['GIT_COMMAND'] : 'git';
|
||||
$envs = isset($_SERVER['GIT_ENVS']) ? (array) $_SERVER['GIT_ENVS'] : array();
|
||||
|
||||
return array(
|
||||
'command' => $command,
|
||||
'environment_variables' => $envs,
|
||||
'process_timeout' => 60,
|
||||
);
|
||||
}
|
||||
}
|
177
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/AdminTest.php
vendored
Normal file
177
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/AdminTest.php
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Admin;
|
||||
use Gitonomy\Git\Reference\Branch;
|
||||
use Gitonomy\Git\Repository;
|
||||
|
||||
class AdminTest extends AbstractTest
|
||||
{
|
||||
private $tmpDir;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->tmpDir = self::createTempDir();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->deleteDir(self::createTempDir());
|
||||
}
|
||||
|
||||
public function testBare()
|
||||
{
|
||||
$repository = Admin::init($this->tmpDir, true, self::getOptions());
|
||||
|
||||
$objectDir = $this->tmpDir.'/objects';
|
||||
|
||||
$this->assertTrue($repository->isBare(), 'Repository is bare');
|
||||
$this->assertTrue(is_dir($objectDir), 'objects/ folder is present');
|
||||
$this->assertTrue($repository instanceof Repository, 'Admin::init returns a repository');
|
||||
$this->assertEquals($this->tmpDir, $repository->getGitDir(), 'The folder passed as argument is git dir');
|
||||
$this->assertNull($repository->getWorkingDir(), 'No working dir in bare repository');
|
||||
}
|
||||
|
||||
public function testNotBare()
|
||||
{
|
||||
$repository = Admin::init($this->tmpDir, false, self::getOptions());
|
||||
|
||||
$objectDir = $this->tmpDir.'/.git/objects';
|
||||
|
||||
$this->assertFalse($repository->isBare(), 'Repository is not bare');
|
||||
$this->assertTrue(is_dir($objectDir), 'objects/ folder is present');
|
||||
$this->assertTrue($repository instanceof Repository, 'Admin::init returns a repository');
|
||||
$this->assertEquals($this->tmpDir.'/.git', $repository->getGitDir(), 'git dir as subfolder of argument');
|
||||
$this->assertEquals($this->tmpDir, $repository->getWorkingDir(), 'working dir present in bare repository');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testClone($repository)
|
||||
{
|
||||
$newDir = self::createTempDir();
|
||||
$new = $repository->cloneTo($newDir, $repository->isBare(), 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));
|
||||
|
||||
if ($repository->isBare()) {
|
||||
$this->assertEquals($newDir, $new->getGitDir());
|
||||
$this->assertTrue(in_array('refs/heads/new-feature', $newRefs));
|
||||
} else {
|
||||
$this->assertEquals($newDir.'/.git', $new->getGitDir());
|
||||
$this->assertEquals($newDir, $new->getWorkingDir());
|
||||
}
|
||||
}
|
||||
|
||||
public function testCloneBranchBare()
|
||||
{
|
||||
//we can't use AbstractText::createFoobarRepository()
|
||||
//because it does not clone other branches than "master"
|
||||
//so we test it directly against the remote repository
|
||||
|
||||
$newDir = self::createTempDir();
|
||||
$new = Admin::cloneBranchTo($newDir, self::REPOSITORY_URL, 'new-feature');
|
||||
self::registerDeletion($new);
|
||||
|
||||
$head = $new->getHead();
|
||||
$this->assertTrue($head instanceof Branch, 'HEAD is a branch');
|
||||
$this->assertEquals('new-feature', $head->getName(), 'HEAD is branch new-feature');
|
||||
}
|
||||
|
||||
public function testCloneBranchNotBare()
|
||||
{
|
||||
//we can't use AbstractText::createFoobarRepository()
|
||||
//because it does not clone other branches than "master"
|
||||
//so we test it directly against remote repository
|
||||
|
||||
$newDir = self::createTempDir();
|
||||
$new = Admin::cloneBranchTo($newDir, self::REPOSITORY_URL, 'new-feature', false);
|
||||
self::registerDeletion($new);
|
||||
|
||||
$head = $new->getHead();
|
||||
$this->assertTrue($head instanceof Branch, 'HEAD is a branch');
|
||||
$this->assertEquals('new-feature', $head->getName(), 'HEAD is branch new-feature');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testMirror($repository)
|
||||
{
|
||||
$newDir = self::createTempDir();
|
||||
$new = Admin::mirrorTo($newDir, $repository->getGitDir(), 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, $new->getGitDir());
|
||||
|
||||
if ($repository->isBare()) {
|
||||
$this->assertTrue(in_array('refs/heads/new-feature', $newRefs));
|
||||
} else {
|
||||
$this->assertTrue(in_array('refs/remotes/origin/new-feature', $newRefs));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testCheckValidRepository($repository)
|
||||
{
|
||||
$url = $repository->getGitDir();
|
||||
$this->assertTrue(Admin::isValidRepository($url));
|
||||
}
|
||||
|
||||
public function testCheckInvalidRepository()
|
||||
{
|
||||
$url = $this->tmpDir.'/invalid.git';
|
||||
mkdir($url);
|
||||
|
||||
$this->assertFalse(Admin::isValidRepository($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testExistingFile()
|
||||
{
|
||||
$file = $this->tmpDir.'/test';
|
||||
touch($file);
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
43
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/BlameTest.php
vendored
Normal file
43
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/BlameTest.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
class BlameTest extends AbstractTest
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testBlame($repository)
|
||||
{
|
||||
$blame = $repository->getBlame(self::LONGFILE_COMMIT, 'README.md');
|
||||
|
||||
$this->assertCount(7, $blame);
|
||||
|
||||
$this->assertEquals('alice', $blame->getLine(1)->getCommit()->getAuthorName());
|
||||
$this->assertEquals(self::INITIAL_COMMIT, $blame->getLine(1)->getCommit()->getHash());
|
||||
|
||||
$this->assertEquals('alice', $blame->getLine(5)->getCommit()->getAuthorName());
|
||||
$this->assertNotEquals(self::INITIAL_COMMIT, $blame->getLine(5)->getCommit()->getHash());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGroupedBlame($repository)
|
||||
{
|
||||
$blame = $repository->getBlame(self::LONGFILE_COMMIT, 'README.md')->getGroupedLines();
|
||||
|
||||
$this->assertCount(3, $blame);
|
||||
|
||||
$this->assertEquals(self::INITIAL_COMMIT, $blame[0][0]->getHash());
|
||||
}
|
||||
}
|
69
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/BlobTest.php
vendored
Normal file
69
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/BlobTest.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
class BlobTest extends AbstractTest
|
||||
{
|
||||
const README_FRAGMENT = 'Foo Bar project';
|
||||
|
||||
public function getReadmeBlob($repository)
|
||||
{
|
||||
return $repository->getCommit(self::LONGFILE_COMMIT)->getTree()->resolvePath('README.md');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetContent($repository)
|
||||
{
|
||||
$blob = $this->getReadmeBlob($repository);
|
||||
|
||||
$this->assertContains(self::README_FRAGMENT, $blob->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testNotExisting($repository)
|
||||
{
|
||||
$blob = $repository->getBlob('foobar');
|
||||
$blob->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetMimetype($repository)
|
||||
{
|
||||
$blob = $this->getReadmeBlob($repository);
|
||||
$this->assertRegexp('#text/plain#', $blob->getMimetype());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testIsText($repository)
|
||||
{
|
||||
$blob = $this->getReadmeBlob($repository);
|
||||
$this->assertTrue($blob->isText());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testIsBinary($repository)
|
||||
{
|
||||
$blob = $this->getReadmeBlob($repository);
|
||||
$this->assertFalse($blob->isBinary());
|
||||
}
|
||||
}
|
301
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/CommitTest.php
vendored
Normal file
301
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/CommitTest.php
vendored
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Commit;
|
||||
use Gitonomy\Git\Diff\Diff;
|
||||
|
||||
class CommitTest extends AbstractTest
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetDiff($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$diff = $commit->getDiff();
|
||||
|
||||
$this->assertTrue($diff instanceof Diff, 'getDiff() returns a Diff object');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetHash($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals(self::LONGFILE_COMMIT, $commit->getHash());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*
|
||||
* @expectedException Gitonomy\Git\Exception\ReferenceNotFoundException
|
||||
* @expectedExceptionMessage Reference not found: "that-hash-doest-not-exists"
|
||||
*/
|
||||
public function testInvalideHashThrowException($repository)
|
||||
{
|
||||
$commit = new Commit($repository, 'that-hash-doest-not-exists');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetShortHash($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('4f17752', $commit->getShortHash(), 'Short hash');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetParentHashes_WithNoParent($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::INITIAL_COMMIT);
|
||||
|
||||
$this->assertEquals(0, count($commit->getParentHashes()), 'No parent on initial commit');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetParentHashes_WithOneParent($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
$parents = $commit->getParentHashes();
|
||||
|
||||
$this->assertEquals(1, count($parents), 'One parent found');
|
||||
$this->assertEquals(self::BEFORE_LONGFILE_COMMIT, $parents[0], 'Parent hash is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetParents_WithOneParent($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
$parents = $commit->getParents();
|
||||
|
||||
$this->assertEquals(1, count($parents), 'One parent found');
|
||||
$this->assertTrue($parents[0] instanceof Commit, 'First parent is a Commit object');
|
||||
$this->assertEquals(self::BEFORE_LONGFILE_COMMIT, $parents[0]->getHash(), "First parents's hash is correct");
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetTreeHash($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('b06890c7b10904979d2f69613c2ccda30aafe262', $commit->getTreeHash(), 'Tree hash is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetTree($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertInstanceOf('Gitonomy\Git\Tree', $commit->getTree(), 'Tree is a tree');
|
||||
$this->assertEquals('b06890c7b10904979d2f69613c2ccda30aafe262', $commit->getTree()->getHash(), 'Tree hash is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetAuthorName($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('alice', $commit->getAuthorName(), 'Author name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetAuthorEmail($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('alice@example.org', $commit->getAuthorEmail(), 'Author email');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetAuthorDate($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('2012-12-31 14:21:03', $commit->getAuthorDate()->format('Y-m-d H:i:s'), 'Author date');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetCommitterName($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('alice', $commit->getCommitterName(), 'Committer name');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetCommitterEmail($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('alice@example.org', $commit->getCommitterEmail(), 'Committer email');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetCommitterDate($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('2012-12-31 14:21:03', $commit->getCommitterDate()->format('Y-m-d H:i:s'), 'Committer date');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetMessage($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$this->assertEquals('add a long file'."\n", $commit->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* This test ensures that GPG signed commits does not break the reading of a commit
|
||||
* message.
|
||||
*
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetSignedMessage($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::SIGNED_COMMIT);
|
||||
$this->assertEquals('signed commit'."\n", $commit->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetShortMessage($repository)
|
||||
{
|
||||
// tests with a multi-line message
|
||||
$commit = $repository->getCommit(self::LONGMESSAGE_COMMIT);
|
||||
|
||||
$this->assertEquals('Fixed perm...', $commit->getShortMessage(10));
|
||||
$this->assertEquals('Fixed perm!!!', $commit->getShortMessage(10, false, '!!!'));
|
||||
$this->assertEquals('Fixed permissions!!!', $commit->getShortMessage(10, true, '!!!'));
|
||||
|
||||
// tests with a single-line message
|
||||
$commit = $repository->getCommit(self::INITIAL_COMMIT);
|
||||
|
||||
$this->assertEquals('Add README', $commit->getShortMessage(20));
|
||||
$this->assertEquals('A', $commit->getShortMessage(1, false, ''));
|
||||
$this->assertEquals('Add!!!', $commit->getShortMessage(1, true, '!!!'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetBodyMessage($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGMESSAGE_COMMIT);
|
||||
$message = <<<EOL
|
||||
If you want to know everything,
|
||||
I ran something like `chmox +x test.sh`
|
||||
|
||||
Hello and good bye.
|
||||
|
||||
EOL;
|
||||
|
||||
$this->assertEquals($message, $commit->getBodyMessage());
|
||||
|
||||
$commit = $repository->getCommit(self::INITIAL_COMMIT);
|
||||
|
||||
$this->assertEquals('', $commit->getBodyMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetIncludingBranchesException($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::INITIAL_COMMIT);
|
||||
|
||||
$commit->getIncludingBranches(false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetIncludingBranches($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::INITIAL_COMMIT);
|
||||
|
||||
$branches = $commit->getIncludingBranches(true, false);
|
||||
$this->assertCount(count($repository->getReferences()->getLocalBranches()), $branches);
|
||||
|
||||
$branches = $commit->getIncludingBranches(true, true);
|
||||
$this->assertCount(count($repository->getReferences()->getBranches()), $branches);
|
||||
|
||||
$branches = $commit->getIncludingBranches(false, true);
|
||||
$this->assertCount(count($repository->getReferences()->getRemoteBranches()), $branches);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetLastModification($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::LONGFILE_COMMIT);
|
||||
|
||||
$lastModification = $commit->getLastModification('image.jpg');
|
||||
|
||||
$this->assertTrue($lastModification instanceof Commit, 'Last modification is a Commit object');
|
||||
$this->assertEquals(self::BEFORE_LONGFILE_COMMIT, $lastModification->getHash(), 'Last modification is current commit');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testMergeCommit($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::MERGE_COMMIT);
|
||||
|
||||
$this->assertEquals("Merge branch 'authors'", $commit->getSubjectMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testEncoding($repository)
|
||||
{
|
||||
$commit = $repository->getCommit(self::ENCODING_COMMIT);
|
||||
|
||||
$this->assertEquals('contribute to AUTHORS file', $commit->getSubjectMessage());
|
||||
}
|
||||
}
|
142
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/DiffTest.php
vendored
Normal file
142
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/DiffTest.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Diff\Diff;
|
||||
|
||||
class DiffTest extends AbstractTest
|
||||
{
|
||||
const DELETE_COMMIT = '519d5693c72c925cd59205d9f11e9fa1d550028b';
|
||||
const CREATE_COMMIT = 'e6fa3c792facc06faa049a6938c84c411954deb5';
|
||||
const RENAME_COMMIT = '6640e0ef31518054847a1876328e26ee64083e0a';
|
||||
const CHANGEMODE_COMMIT = '93da965f58170f13017477b9a608657e87e23230';
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testSerialization($repository)
|
||||
{
|
||||
$data = $repository->getCommit(self::CREATE_COMMIT)->getDiff()->toArray();
|
||||
$diff = Diff::fromArray($data);
|
||||
|
||||
$this->verifyCreateCommitDiff($diff);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetFiles_Addition($repository)
|
||||
{
|
||||
$diff = $repository->getCommit(self::CREATE_COMMIT)->getDiff();
|
||||
$this->verifyCreateCommitDiff($diff);
|
||||
}
|
||||
|
||||
protected function verifyCreateCommitDiff(Diff $diff)
|
||||
{
|
||||
$files = $diff->getFiles();
|
||||
|
||||
$this->assertEquals(2, count($files), '1 file in diff');
|
||||
|
||||
$this->assertTrue($files[0]->isCreation(), 'script_A.php created');
|
||||
|
||||
$this->assertEquals(null, $files[0]->getOldName(), 'First file name is a new file');
|
||||
$this->assertEquals('script_A.php', $files[0]->getNewName(), 'First file name is script_A.php');
|
||||
$this->assertEquals(null, $files[0]->getOldMode(), 'First file mode is a new file');
|
||||
$this->assertEquals('100644', $files[0]->getNewMode(), 'First file mode is correct');
|
||||
|
||||
$this->assertEquals(1, $files[0]->getAdditions(), '1 line added');
|
||||
$this->assertEquals(0, $files[0]->getDeletions(), '0 lines deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetFiles_Modification($repository)
|
||||
{
|
||||
$files = $repository->getCommit(self::BEFORE_LONGFILE_COMMIT)->getDiff()->getFiles();
|
||||
|
||||
$this->assertEquals(1, count($files), '1 files in diff');
|
||||
|
||||
$this->assertTrue($files[0]->isModification(), 'image.jpg modified');
|
||||
|
||||
$this->assertEquals('image.jpg', $files[0]->getOldName(), 'Second file name is image.jpg');
|
||||
$this->assertEquals('image.jpg', $files[0]->getNewName(), 'Second file name is image.jpg');
|
||||
$this->assertEquals('100644', $files[0]->getOldMode(), 'Second file mode is a new file');
|
||||
$this->assertEquals('100644', $files[0]->getNewMode(), 'Second file mode is correct');
|
||||
|
||||
$this->assertTrue($files[0]->isBinary(), 'binary file');
|
||||
$this->assertEquals(0, $files[0]->getAdditions(), '0 lines added');
|
||||
$this->assertEquals(0, $files[0]->getDeletions(), '0 lines deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetFiles_Deletion($repository)
|
||||
{
|
||||
$files = $repository->getCommit(self::DELETE_COMMIT)->getDiff()->getFiles();
|
||||
|
||||
$this->assertEquals(1, count($files), '1 files modified');
|
||||
|
||||
$this->assertTrue($files[0]->isDeletion(), 'File deletion');
|
||||
$this->assertEquals('script_B.php', $files[0]->getOldName(), 'verify old filename');
|
||||
$this->assertEquals(1, $files[0]->getDeletions(), '1 line deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetFiles_Rename($repository)
|
||||
{
|
||||
$files = $repository->getCommit(self::RENAME_COMMIT)->getDiff()->getFiles();
|
||||
|
||||
$this->assertEquals(1, count($files), '1 files modified');
|
||||
|
||||
$this->assertTrue($files[0]->isModification());
|
||||
$this->assertTrue($files[0]->isRename());
|
||||
$this->assertFalse($files[0]->isDeletion());
|
||||
$this->assertFalse($files[0]->isCreation());
|
||||
$this->assertFalse($files[0]->isChangeMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetFiles_Changemode($repository)
|
||||
{
|
||||
$files = $repository->getCommit(self::CHANGEMODE_COMMIT)->getDiff()->getFiles();
|
||||
|
||||
$this->assertEquals(1, count($files), '1 files modified');
|
||||
|
||||
$this->assertTrue($files[0]->isModification());
|
||||
$this->assertTrue($files[0]->isChangeMode());
|
||||
$this->assertFalse($files[0]->isDeletion());
|
||||
$this->assertFalse($files[0]->isCreation());
|
||||
$this->assertFalse($files[0]->isRename());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testDiffRangeParse($repository)
|
||||
{
|
||||
$files = $repository->getCommit(self::CREATE_COMMIT)->getDiff()->getFiles();
|
||||
|
||||
$changes = $files[0]->getChanges();
|
||||
|
||||
$this->assertEquals(0, $changes[0]->getRangeOldStart());
|
||||
$this->assertEquals(0, $changes[0]->getRangeOldCount());
|
||||
|
||||
$this->assertEquals(1, $changes[0]->getRangeNewStart());
|
||||
$this->assertEquals(0, $changes[0]->getRangeNewCount());
|
||||
}
|
||||
}
|
178
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/HooksTest.php
vendored
Normal file
178
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/HooksTest.php
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
class HooksTest extends AbstractTest
|
||||
{
|
||||
private static $symlinkOnWindows = null;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
||||
self::$symlinkOnWindows = true;
|
||||
$originDir = tempnam(sys_get_temp_dir(), 'sl');
|
||||
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
|
||||
if (true !== @symlink($originDir, $targetDir)) {
|
||||
$report = error_get_last();
|
||||
if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
|
||||
self::$symlinkOnWindows = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hookPath($repository, $hook)
|
||||
{
|
||||
return $repository->getGitDir().'/hooks/'.$hook;
|
||||
}
|
||||
|
||||
public function touchHook($repository, $hook, $content = '')
|
||||
{
|
||||
$path = $this->hookPath($repository, $hook);
|
||||
file_put_contents($path, $content);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function assertHasHook($repository, $hook)
|
||||
{
|
||||
$file = $this->hookPath($repository, $hook);
|
||||
|
||||
$this->assertTrue($repository->getHooks()->has($hook), "hook $hook in repository");
|
||||
$this->assertTrue(file_exists($file), "Hook $hook is present");
|
||||
}
|
||||
|
||||
public function assertNoHook($repository, $hook)
|
||||
{
|
||||
$file = $this->hookPath($repository, $hook);
|
||||
|
||||
$this->assertFalse($repository->getHooks()->has($hook), "No hook $hook in repository");
|
||||
$this->assertFalse(file_exists($file), "Hook $hook is not present");
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testHas($repository)
|
||||
{
|
||||
$this->assertNoHook($repository, 'foo');
|
||||
$this->touchHook($repository, 'foo');
|
||||
$this->assertHasHook($repository, 'foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testGet_InvalidName_ThrowsException($repository)
|
||||
{
|
||||
$repository->getHooks()->get('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGet($repository)
|
||||
{
|
||||
$this->touchHook($repository, 'foo', 'foobar');
|
||||
|
||||
$this->assertEquals('foobar', $repository->getHooks()->get('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testSymlink($repository)
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$file = $this->touchHook($repository, 'bar', 'barbarbar');
|
||||
$repository->getHooks()->setSymlink('foo', $file);
|
||||
|
||||
$this->assertTrue(is_link($this->hookPath($repository, 'foo')), 'foo hook is a symlink');
|
||||
$this->assertEquals($file, readlink($this->hookPath($repository, 'foo')), 'target of symlink is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function testSymlink_WithExisting_ThrowsLogicException($repository)
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
|
||||
$file = $this->hookPath($repository, 'target-symlink');
|
||||
$fooFile = $this->hookPath($repository, 'foo');
|
||||
|
||||
file_put_contents($file, 'foobar');
|
||||
touch($fooFile);
|
||||
|
||||
$repository->getHooks()->setSymlink('foo', $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testSet($repository)
|
||||
{
|
||||
$file = $this->hookPath($repository, 'foo');
|
||||
$repository->getHooks()->set('foo', 'bar');
|
||||
|
||||
$this->assertEquals('bar', file_get_contents($file), 'Hook content is correct');
|
||||
|
||||
$perms = fileperms($file);
|
||||
$this->assertEquals(defined('PHP_WINDOWS_VERSION_BUILD') ? 0666 : 0777, $perms & 0777, 'Hook permissions are correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testSet_Existing_ThrowsLogicException($repository)
|
||||
{
|
||||
$repository->getHooks()->set('foo', 'bar');
|
||||
|
||||
$this->setExpectedException('LogicException');
|
||||
$repository->getHooks()->set('foo', 'bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testRemove($repository)
|
||||
{
|
||||
$file = $this->hookPath($repository, 'foo');
|
||||
touch($file);
|
||||
|
||||
$repository->getHooks()->remove('foo');
|
||||
$this->assertFalse(file_exists($file));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function testRemove_NotExisting_ThrowsLogicException($repository)
|
||||
{
|
||||
$repository->getHooks()->remove('foo');
|
||||
}
|
||||
|
||||
private function markAsSkippedIfSymlinkIsMissing()
|
||||
{
|
||||
if (!function_exists('symlink')) {
|
||||
$this->markTestSkipped('symlink is not supported');
|
||||
}
|
||||
|
||||
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false === self::$symlinkOnWindows) {
|
||||
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on windows');
|
||||
}
|
||||
}
|
||||
}
|
80
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/LogTest.php
vendored
Normal file
80
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/LogTest.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Log;
|
||||
|
||||
class LogTest extends AbstractTest
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testRevisionAndPath($repository)
|
||||
{
|
||||
$logReadme = $repository->getLog(self::LONGFILE_COMMIT, 'README');
|
||||
$logImage = $repository->getLog(self::LONGFILE_COMMIT, 'image.jpg');
|
||||
|
||||
$this->assertEquals(3, count($logReadme));
|
||||
$this->assertEquals(2, count($logImage));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetCommits($repository)
|
||||
{
|
||||
$log = $repository->getLog(self::LONGFILE_COMMIT, null, null, 3);
|
||||
|
||||
$commits = $log->getCommits();
|
||||
|
||||
$this->assertEquals(3, count($commits), '3 commits in log');
|
||||
$this->assertEquals(self::LONGFILE_COMMIT, $commits[0]->getHash(), 'First is requested one');
|
||||
$this->assertEquals(self::BEFORE_LONGFILE_COMMIT, $commits[1]->getHash(), "Second is longfile parent\'s");
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testCountCommits($repository)
|
||||
{
|
||||
$log = $repository->getLog(self::LONGFILE_COMMIT, null, 2, 3);
|
||||
|
||||
$this->assertEquals(8, $log->countCommits(), '8 commits found in history');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testCountAllCommits($repository)
|
||||
{
|
||||
$log = $log = $repository->getLog();
|
||||
|
||||
$this->assertGreaterThan(100, $log->countCommits(), 'Returns all commits from all branches');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testIterable($repository)
|
||||
{
|
||||
$log = $repository->getLog(self::LONGFILE_COMMIT);
|
||||
|
||||
$expectedHashes = array(self::LONGFILE_COMMIT, self::BEFORE_LONGFILE_COMMIT);
|
||||
foreach ($log as $entry) {
|
||||
$hash = array_shift($expectedHashes);
|
||||
$this->assertEquals($hash, $entry->getHash());
|
||||
if (count($expectedHashes) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
82
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/PushReferenceTest.php
vendored
Normal file
82
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/PushReferenceTest.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\PushReference;
|
||||
|
||||
class PushReferenceTest extends AbstractTest
|
||||
{
|
||||
const CREATE = 1;
|
||||
const DELETE = 2;
|
||||
const FORCE = 4;
|
||||
const FAST_FORWARD = 8;
|
||||
|
||||
public function provideIsers()
|
||||
{
|
||||
// mask: force fastforward create delete
|
||||
return array(
|
||||
array('foo', PushReference::ZERO, self::LONGFILE_COMMIT, self::CREATE),
|
||||
array('foo', self::LONGFILE_COMMIT, PushReference::ZERO, self::DELETE),
|
||||
array('foo', self::LONGFILE_COMMIT, self::BEFORE_LONGFILE_COMMIT, self::FORCE),
|
||||
array('foo', self::BEFORE_LONGFILE_COMMIT, self::LONGFILE_COMMIT, self::FAST_FORWARD),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideIsers
|
||||
*/
|
||||
public function testIsers($reference, $before, $after, $mask)
|
||||
{
|
||||
$reference = new PushReference(self::createFoobarRepository(), $reference, $before, $after);
|
||||
$this->assertEquals($mask & self::CREATE, $reference->isCreate(), 'Create value is correct.');
|
||||
$this->assertEquals($mask & self::DELETE, $reference->isDelete(), 'Delete value is correct.');
|
||||
$this->assertEquals($mask & self::FORCE, $reference->isForce(), 'Force value is correct.');
|
||||
$this->assertEquals($mask & self::FAST_FORWARD, $reference->isFastForward(), 'FastForward value is correct.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testLog($repository)
|
||||
{
|
||||
$ref = new PushReference($repository, 'foo', self::INITIAL_COMMIT, self::LONGFILE_COMMIT);
|
||||
|
||||
$log = $ref->getLog()->getCommits();
|
||||
$this->assertEquals(7, count($log), '7 commits in log');
|
||||
$this->assertEquals('add a long file', $log[0]->getShortMessage(), 'First commit is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* This test ensures that GPG signed requests does not break the reading of commit logs.
|
||||
*
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testSignedLog($repository)
|
||||
{
|
||||
$ref = new PushReference($repository, 'foo', self::INITIAL_COMMIT, self::SIGNED_COMMIT);
|
||||
$log = $ref->getLog()->getCommits();
|
||||
$this->assertEquals(16, count($log), '16 commits in log');
|
||||
$this->assertEquals('signed commit', $log[0]->getShortMessage(), 'Last commit is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testLogWithExclude($repository)
|
||||
{
|
||||
$ref = new PushReference($repository, 'foo', PushReference::ZERO, self::LONGFILE_COMMIT);
|
||||
|
||||
$log = $ref->getLog(array(self::INITIAL_COMMIT))->getCommits();
|
||||
$this->assertEquals(7, count($log), '7 commits in log');
|
||||
$this->assertEquals('add a long file', $log[0]->getShortMessage(), 'First commit is correct');
|
||||
}
|
||||
}
|
183
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/ReferenceTest.php
vendored
Normal file
183
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/ReferenceTest.php
vendored
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Reference\Branch;
|
||||
use Gitonomy\Git\Reference\Tag;
|
||||
|
||||
class ReferenceTest extends AbstractTest
|
||||
{
|
||||
private $references;
|
||||
|
||||
/**
|
||||
* @dataProvider provideEmpty
|
||||
*/
|
||||
public function testEmptyRepository($repository)
|
||||
{
|
||||
$this->assertCount(0, $repository->getReferences());
|
||||
$this->assertEquals(array(), $repository->getReferences()->getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetBranch($repository)
|
||||
{
|
||||
$branch = $repository->getReferences()->getBranch('master');
|
||||
|
||||
$this->assertTrue($branch instanceof Branch, 'Branch object is correct type');
|
||||
$this->assertEquals($branch->getCommitHash(), $branch->getCommit()->getHash(), 'Hash is correctly resolved');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testHasBranch($repository)
|
||||
{
|
||||
$this->assertTrue($repository->getReferences()->hasBranch('master'), 'Branch master exists');
|
||||
$this->assertFalse($repository->getReferences()->hasBranch('foobar'), 'Branch foobar does not exists');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testHasTag($repository)
|
||||
{
|
||||
$this->assertTrue($repository->getReferences()->hasTag('0.1'), 'Tag 0.1 exists');
|
||||
$this->assertFalse($repository->getReferences()->hasTag('foobar'), 'Tag foobar does not exists');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException Gitonomy\Git\Exception\ReferenceNotFoundException
|
||||
*/
|
||||
public function testGetBranch_NotExisting_Error($repository)
|
||||
{
|
||||
$branch = $repository->getReferences()->getBranch('notexisting');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetTag($repository)
|
||||
{
|
||||
$tag = $repository->getReferences()->getTag('0.1');
|
||||
|
||||
$this->assertTrue($tag instanceof Tag, 'Tag object is correct type');
|
||||
|
||||
$this->assertEquals(self::LONGFILE_COMMIT, $tag->getCommitHash(), 'Commit hash is correct');
|
||||
$this->assertEquals(self::LONGFILE_COMMIT, $tag->getCommit()->getHash(), 'Commit hash is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException Gitonomy\Git\Exception\ReferenceNotFoundException
|
||||
*/
|
||||
public function testGetTag_NotExisting_Error($repository)
|
||||
{
|
||||
$branch = $repository->getReferences()->getTag('notexisting');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testResolve($repository)
|
||||
{
|
||||
$commit = $repository->getReferences()->getTag('0.1')->getCommit();
|
||||
$resolved = $repository->getReferences()->resolve($commit->getHash());
|
||||
|
||||
$this->assertEquals(1, count($resolved), '1 revision resolved');
|
||||
$this->assertTrue(reset($resolved) instanceof Tag, 'Resolved object is a tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testResolveTags($repository)
|
||||
{
|
||||
$commit = $repository->getReferences()->getTag('0.1')->getCommit();
|
||||
$resolved = $repository->getReferences()->resolveTags($commit->getHash());
|
||||
|
||||
$this->assertEquals(1, count($resolved), '1 revision resolved');
|
||||
$this->assertTrue(reset($resolved) instanceof Tag, 'Resolved object is a tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testResolveBranches($repository)
|
||||
{
|
||||
$master = $repository->getReferences()->getBranch('master');
|
||||
|
||||
$resolved = $repository->getReferences()->resolveBranches($master->getCommitHash());
|
||||
|
||||
if ($repository->isBare()) {
|
||||
$this->assertEquals(1, count($resolved), '1 revision resolved');
|
||||
} else {
|
||||
$this->assertEquals(2, count($resolved), '2 revision resolved');
|
||||
}
|
||||
|
||||
$this->assertTrue(reset($resolved) instanceof Branch, 'Resolved object is a branch');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testCountable($repository)
|
||||
{
|
||||
$this->assertGreaterThanOrEqual(2, count($repository->getReferences()), 'At least two references in repository');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testIterable($repository)
|
||||
{
|
||||
$i = 0;
|
||||
foreach ($repository->getReferences() as $ref) {
|
||||
++$i;
|
||||
}
|
||||
$this->assertGreaterThanOrEqual(2, $i, 'At least two references in repository');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testCreateAndDeleteTag($repository)
|
||||
{
|
||||
$references = $repository->getReferences();
|
||||
$tag = $references->createTag('0.0', self::INITIAL_COMMIT);
|
||||
|
||||
$this->assertTrue($references->hasTag('0.0'), 'Tag 0.0 created');
|
||||
$this->assertEquals(self::INITIAL_COMMIT, $tag->getCommit()->getHash());
|
||||
$this->assertSame($tag, $references->getTag('0.0'));
|
||||
|
||||
$tag->delete();
|
||||
$this->assertFalse($references->hasTag('0.0'), 'Tag 0.0 removed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testCreateAndDeleteBranch($repository)
|
||||
{
|
||||
$references = $repository->getReferences();
|
||||
$branch = $references->createBranch('foobar', self::INITIAL_COMMIT);
|
||||
|
||||
$this->assertTrue($references->hasBranch('foobar'), 'Branch foobar created');
|
||||
$this->assertEquals(self::INITIAL_COMMIT, $branch->getCommit()->getHash());
|
||||
$this->assertSame($branch, $references->getBranch('foobar'));
|
||||
|
||||
$branch->delete();
|
||||
$this->assertFalse($references->hasBranch('foobar'), 'Branch foobar removed');
|
||||
}
|
||||
}
|
109
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/RepositoryTest.php
vendored
Normal file
109
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/RepositoryTest.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Blob;
|
||||
use Gitonomy\Git\Repository;
|
||||
use Prophecy\Argument;
|
||||
|
||||
class RepositoryTest extends AbstractTest
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetBlob_WithExisting_Works($repository)
|
||||
{
|
||||
$blob = $repository->getCommit(self::LONGFILE_COMMIT)->getTree()->resolvePath('README.md');
|
||||
|
||||
$this->assertTrue($blob instanceof Blob, 'getBlob() returns a Blob object');
|
||||
$this->assertContains('Foo Bar project', $blob->getContent(), 'file is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetSize($repository)
|
||||
{
|
||||
$size = $repository->getSize();
|
||||
$this->assertGreaterThan(70, $size, 'Repository is greater than 70KB');
|
||||
}
|
||||
|
||||
public function testIsBare()
|
||||
{
|
||||
$bare = self::createFoobarRepository(true);
|
||||
$this->assertTrue($bare->isBare(), 'Lib repository is bare');
|
||||
|
||||
$notBare = self::createFoobarRepository(false);
|
||||
$this->assertFalse($notBare->isBare(), 'Working copy is not bare');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetDescription($repository)
|
||||
{
|
||||
$this->assertSame("Unnamed repository; edit this file 'description' to name the repository.\n", $repository->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testLoggerOk($repository)
|
||||
{
|
||||
if (!interface_exists('Psr\Log\LoggerInterface')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$loggerProphecy = $this->prophesize('Psr\Log\LoggerInterface');
|
||||
$loggerProphecy
|
||||
->info('run command: remote "" ')
|
||||
->shouldBeCalledTimes(1)
|
||||
;
|
||||
$loggerProphecy
|
||||
->debug(Argument::type('string')) // duration, return code and output
|
||||
->shouldBeCalledTimes(3)
|
||||
;
|
||||
|
||||
$repository->setLogger($loggerProphecy->reveal());
|
||||
|
||||
$repository->run('remote');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testLoggerNOk($repository)
|
||||
{
|
||||
if (!interface_exists('Psr\Log\LoggerInterface')) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
$loggerProphecy = $this->prophesize('Psr\Log\LoggerInterface');
|
||||
$loggerProphecy
|
||||
->info(Argument::type('string'))
|
||||
->shouldBeCalledTimes(1)
|
||||
;
|
||||
$loggerProphecy
|
||||
->debug(Argument::type('string')) // duration, return code and output
|
||||
->shouldBeCalledTimes(3)
|
||||
;
|
||||
$loggerProphecy
|
||||
->error(Argument::type('string'))
|
||||
->shouldBeCalledTimes(1)
|
||||
;
|
||||
|
||||
$repository->setLogger($loggerProphecy->reveal());
|
||||
|
||||
$repository->run('not-work');
|
||||
}
|
||||
}
|
60
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/RevisionTest.php
vendored
Normal file
60
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/RevisionTest.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Commit;
|
||||
use Gitonomy\Git\Log;
|
||||
use Gitonomy\Git\Revision;
|
||||
|
||||
class RevisionTest extends AbstractTest
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetCommit($repository)
|
||||
{
|
||||
$revision = $repository->getRevision(self::LONGFILE_COMMIT.'^');
|
||||
|
||||
$this->assertTrue($revision instanceof Revision, 'Revision object type');
|
||||
|
||||
$commit = $revision->getCommit();
|
||||
|
||||
$this->assertTrue($commit instanceof Commit, 'getCommit returns a Commit');
|
||||
|
||||
$this->assertEquals(self::BEFORE_LONGFILE_COMMIT, $commit->getHash(), 'Resolution is correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
* @expectedException Gitonomy\Git\Exception\ReferenceNotFoundException
|
||||
* @expectedExceptionMessage Can not find revision "non-existent-commit"
|
||||
*/
|
||||
public function testGetFailingReference($repository)
|
||||
{
|
||||
$revision = $repository->getRevision('non-existent-commit')->getCommit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFoobar
|
||||
*/
|
||||
public function testGetLog($repository)
|
||||
{
|
||||
$revision = $repository->getRevision(self::LONGFILE_COMMIT);
|
||||
|
||||
$log = $revision->getLog(null, 2, 3);
|
||||
|
||||
$this->assertTrue($log instanceof Log, 'Log type object');
|
||||
$this->assertEquals(2, $log->getOffset(), 'Log offset is passed');
|
||||
$this->assertEquals(3, $log->getLimit(), 'Log limit is passed');
|
||||
$this->assertEquals(array($revision), $log->getRevisions()->getAll(), 'Revision is passed');
|
||||
}
|
||||
}
|
48
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/TreeTest.php
vendored
Normal file
48
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/TreeTest.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Blob;
|
||||
|
||||
class TreeTest extends AbstractTest
|
||||
{
|
||||
const PATH_RESOLVING_COMMIT = 'cc06ac171d884282202dff88c1ded499a1f89420';
|
||||
/**
|
||||
* @dataProvider provideFooBar
|
||||
*/
|
||||
public function testCase($repository)
|
||||
{
|
||||
$tree = $repository->getCommit(self::LONGFILE_COMMIT)->getTree();
|
||||
|
||||
$entries = $tree->getEntries();
|
||||
|
||||
$this->assertTrue(isset($entries['long.php']), 'long.php is present');
|
||||
$this->assertTrue($entries['long.php'][1] instanceof Blob, 'long.php is a Blob');
|
||||
|
||||
$this->assertTrue(isset($entries['README.md']), 'README.md is present');
|
||||
$this->assertTrue($entries['README.md'][1] instanceof Blob, 'README.md is a Blob');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFooBar
|
||||
*/
|
||||
public function testResolvePath($repository)
|
||||
{
|
||||
$tree = $repository->getCommit(self::PATH_RESOLVING_COMMIT)->getTree();
|
||||
$path = 'test/a/b/c';
|
||||
|
||||
$resolved = $tree->resolvePath($path);
|
||||
$entries = $resolved->getEntries();
|
||||
|
||||
$this->assertTrue(isset($entries['d']), 'Successfully resolved source folder');
|
||||
}
|
||||
}
|
112
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/WorkingCopyTest.php
vendored
Normal file
112
vendor/gitonomy/gitlib/tests/Gitonomy/Git/Tests/WorkingCopyTest.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Gitonomy.
|
||||
*
|
||||
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
|
||||
* (c) Julien DIDIER <genzo.wm@gmail.com>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
namespace Gitonomy\Git\Tests;
|
||||
|
||||
use Gitonomy\Git\Admin;
|
||||
use Gitonomy\Git\Reference\Branch;
|
||||
|
||||
class WorkingCopyTest extends AbstractTest
|
||||
{
|
||||
/**
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function testNoWorkingCopyInBare()
|
||||
{
|
||||
$path = self::createTempDir();
|
||||
$repo = Admin::init($path, true, self::getOptions());
|
||||
|
||||
$repo->getWorkingCopy();
|
||||
}
|
||||
|
||||
public function testCheckout()
|
||||
{
|
||||
$repository = self::createFoobarRepository(false);
|
||||
$wc = $repository->getWorkingCopy();
|
||||
$wc->checkout('origin/new-feature', 'new-feature');
|
||||
|
||||
$head = $repository->getHead();
|
||||
$this->assertTrue($head instanceof Branch, 'HEAD is a branch');
|
||||
$this->assertEquals('new-feature', $head->getName(), 'HEAD is branch new-feature');
|
||||
}
|
||||
|
||||
public function testDiffStaged()
|
||||
{
|
||||
$repository = self::createFoobarRepository(false);
|
||||
$wc = $repository->getWorkingCopy();
|
||||
|
||||
$diffStaged = $wc->getDiffStaged();
|
||||
$this->assertCount(0, $diffStaged->getFiles());
|
||||
|
||||
$file = $repository->getWorkingDir().'/foobar-test';
|
||||
file_put_contents($file, 'test');
|
||||
$repository->run('add', array($file));
|
||||
|
||||
$diffStaged = $wc->getDiffStaged();
|
||||
$this->assertCount(1, $diffStaged->getFiles());
|
||||
}
|
||||
|
||||
public function testDiffPending()
|
||||
{
|
||||
$repository = self::createFoobarRepository(false);
|
||||
$wc = $repository->getWorkingCopy();
|
||||
|
||||
$diffPending = $wc->getDiffPending();
|
||||
$this->assertCount(0, $diffPending->getFiles());
|
||||
|
||||
$file = $repository->getWorkingDir().'/test.sh';
|
||||
file_put_contents($file, 'test');
|
||||
|
||||
$diffPending = $wc->getDiffPending();
|
||||
$this->assertCount(1, $diffPending->getFiles());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testCheckoutUnexisting()
|
||||
{
|
||||
self::createFoobarRepository(false)->getWorkingCopy()->checkout('foobar');
|
||||
}
|
||||
|
||||
public function testAttachedHead()
|
||||
{
|
||||
$repository = self::createFoobarRepository(false);
|
||||
$wc = $repository->getWorkingCopy();
|
||||
$wc->checkout('master');
|
||||
|
||||
$head = $repository->getHead();
|
||||
$this->assertTrue($repository->isHeadAttached(), 'HEAD is attached');
|
||||
$this->assertFalse($repository->isHeadDetached(), 'HEAD is not detached');
|
||||
}
|
||||
|
||||
public function testDetachedHead()
|
||||
{
|
||||
$repository = self::createFoobarRepository(false);
|
||||
$wc = $repository->getWorkingCopy();
|
||||
$wc->checkout('0.1');
|
||||
|
||||
$head = $repository->getHead();
|
||||
$this->assertFalse($repository->isHeadAttached(), 'HEAD is not attached');
|
||||
$this->assertTrue($repository->isHeadDetached(), 'HEAD is detached');
|
||||
}
|
||||
|
||||
public function testGetUntracked()
|
||||
{
|
||||
$repository = self::createFoobarRepository(false);
|
||||
$wc = $repository->getWorkingCopy();
|
||||
|
||||
$file = $repository->getWorkingDir().'/untracked.txt';
|
||||
file_put_contents($file, 'foo');
|
||||
|
||||
$this->assertContains('untracked.txt', $wc->getUntrackedFiles());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user