mirror of
https://github.com/klaussilveira/gitlist.git
synced 2026-09-01 04:57:17 +02:00
Fixed unresolvable TMP dir on Windows
This commit is contained in:
@@ -8,22 +8,32 @@ use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
class ClientTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
const PATH = '/tmp/gitlist';
|
||||
protected static $tmpdir = '/tmp/gitlist';
|
||||
|
||||
protected $client;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
mkdir(ClientTest::PATH);
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
self::$tmpdir = getenv('TMP').'/gitlist';
|
||||
}
|
||||
|
||||
$fs = new Filesystem();
|
||||
$fs->mkdir(self::$tmpdir);
|
||||
|
||||
if (!is_writable(self::$tmpdir)) {
|
||||
$this->markTestSkipped('There are no write permissions in order to create test repositories.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (!is_writable(ClientTest::PATH)) {
|
||||
if (!is_writable(self::$tmpdir)) {
|
||||
$this->markTestSkipped('There are no write permissions in order to create test repositories.');
|
||||
}
|
||||
|
||||
$options['path'] = getenv('GIT_CLIENT') ?: '/usr/bin/git';
|
||||
$options['hidden'] = array(ClientTest::PATH . '/hiddenrepo');
|
||||
$options['hidden'] = array(self::$tmpdir . '/hiddenrepo');
|
||||
$this->client = new Client($options);
|
||||
}
|
||||
|
||||
@@ -32,7 +42,7 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testIsNotFindingRepositories()
|
||||
{
|
||||
$this->client->getRepositories(ClientTest::PATH . '/testrepo');
|
||||
$this->client->getRepositories(self::$tmpdir . '/testrepo');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +50,7 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testIsNotAbleToGetUnexistingRepository()
|
||||
{
|
||||
$this->client->getRepository(ClientTest::PATH . '/testrepo');
|
||||
$this->client->getRepository(self::$tmpdir . '/testrepo');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,10 +60,10 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->client->getRepositories('/tmp');
|
||||
}
|
||||
|
||||
|
||||
public function testIsCreatingRepository()
|
||||
{
|
||||
$repository = $this->client->createRepository(ClientTest::PATH . '/testrepo');
|
||||
$repository = $this->client->createRepository(self::$tmpdir . '/testrepo');
|
||||
$this->assertRegExp("/nothing to commit/", $repository->getClient()->run($repository, 'status'));
|
||||
}
|
||||
|
||||
@@ -62,14 +72,14 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testIsNotAbleToCreateRepositoryDueToExistingOne()
|
||||
{
|
||||
$this->client->createRepository(ClientTest::PATH . '/testrepo');
|
||||
$this->client->createRepository(self::$tmpdir . '/testrepo');
|
||||
}
|
||||
|
||||
public function testIsListingRepositories()
|
||||
{
|
||||
$this->client->createRepository(ClientTest::PATH . '/anothertestrepo');
|
||||
$this->client->createRepository(ClientTest::PATH . '/bigbadrepo');
|
||||
$repositories = $this->client->getRepositories(ClientTest::PATH);
|
||||
$this->client->createRepository(self::$tmpdir . '/anothertestrepo');
|
||||
$this->client->createRepository(self::$tmpdir . '/bigbadrepo');
|
||||
$repositories = $this->client->getRepositories(self::$tmpdir);
|
||||
|
||||
$this->assertEquals($repositories[0]['name'], 'anothertestrepo');
|
||||
$this->assertEquals($repositories[1]['name'], 'bigbadrepo');
|
||||
@@ -78,8 +88,8 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testIsNotListingHiddenRepositories()
|
||||
{
|
||||
$this->client->createRepository(ClientTest::PATH . '/hiddenrepo');
|
||||
$repositories = $this->client->getRepositories(ClientTest::PATH);
|
||||
$this->client->createRepository(self::$tmpdir . '/hiddenrepo');
|
||||
$repositories = $this->client->getRepositories(self::$tmpdir);
|
||||
|
||||
$this->assertEquals($repositories[0]['name'], 'anothertestrepo');
|
||||
$this->assertEquals($repositories[1]['name'], 'bigbadrepo');
|
||||
@@ -92,7 +102,7 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testIsNotOpeningHiddenRepositories()
|
||||
{
|
||||
$this->client->getRepository(ClientTest::PATH . '/hiddenrepo');
|
||||
$this->client->getRepository(self::$tmpdir . '/hiddenrepo');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,13 +110,13 @@ class ClientTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testIsCatchingGitCommandErrors()
|
||||
{
|
||||
$repository = $this->client->getRepository(ClientTest::PATH . '/testrepo');
|
||||
$repository = $this->client->getRepository(self::$tmpdir . '/testrepo');
|
||||
$repository->getClient()->run($repository, 'wrong');
|
||||
}
|
||||
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$fs = new Filesystem();
|
||||
$fs->remove(ClientTest::PATH);
|
||||
$fs->remove(self::$tmpdir);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user