diff --git a/tests/ClientTest.php b/tests/ClientTest.php index e24ed5d..7dffa3d 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -8,15 +8,13 @@ use Symfony\Component\Filesystem\Filesystem; class ClientTest extends PHPUnit_Framework_TestCase { - protected static $tmpdir = '/tmp/gitlist'; + protected static $tmpdir; protected $client; public static function setUpBeforeClass() { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - self::$tmpdir = getenv('TMP').'/gitlist'; - } + self::$tmpdir = str_replace('\\', '/', getenv('TMP') .'/gitlist_' . md5(time() . mt_rand())); $fs = new Filesystem(); $fs->mkdir(self::$tmpdir); @@ -58,7 +56,7 @@ class ClientTest extends PHPUnit_Framework_TestCase */ public function testIsNotAbleToGetUnexistingRepositories() { - $this->client->getRepositories('/tmp'); + $this->client->getRepositories(self::$tmpdir); } public function testIsCreatingRepository() @@ -117,6 +115,11 @@ class ClientTest extends PHPUnit_Framework_TestCase public static function tearDownAfterClass() { $fs = new Filesystem(); - $fs->remove(self::$tmpdir); + + try { + //$fs->remove(self::$tmpdir); + } catch (IOException $e) { + // Ignore, file is not closed yet + } } } diff --git a/tests/InterfaceTest.php b/tests/InterfaceTest.php index c1ce201..80ac82b 100644 --- a/tests/InterfaceTest.php +++ b/tests/InterfaceTest.php @@ -4,17 +4,16 @@ require 'vendor/autoload.php'; use Silex\WebTestCase; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Exception\IOException; use GitList\Component\Git\Client; class InterfaceTest extends WebTestCase { - protected static $tmpdir = '/tmp/gitlist'; + protected static $tmpdir; public static function setUpBeforeClass() { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - self::$tmpdir = getenv('TMP').'/gitlist'; - } + self::$tmpdir = getenv('TMP').'/gitlist_' . md5(time() . mt_rand()) . '/'; $fs = new Filesystem(); $fs->mkdir(self::$tmpdir); @@ -197,6 +196,11 @@ class InterfaceTest extends WebTestCase public static function tearDownAfterClass() { $fs = new Filesystem(); - $fs->remove(self::$tmpdir); + + try { + $fs->remove(self::$tmpdir); + } catch (IOException $e) { + // Ignore, file is not closed yet + } } } diff --git a/tests/RepositoryTest.php b/tests/RepositoryTest.php index 428176f..d84c948 100644 --- a/tests/RepositoryTest.php +++ b/tests/RepositoryTest.php @@ -14,9 +14,7 @@ class RepositoryTest extends PHPUnit_Framework_TestCase public static function setUpBeforeClass() { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - self::$tmpdir = getenv('TMP').'/gitlist'; - } + self::$tmpdir = getenv('TMP').'/gitlist_' . md5(time() . mt_rand()) . '/'; $fs = new Filesystem(); $fs->mkdir(self::$tmpdir); @@ -332,6 +330,10 @@ class RepositoryTest extends PHPUnit_Framework_TestCase public function testIsGettingSymlinksWithinTrees() { + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $this->markTestSkipped('Unable to run on Windows'); + } + $repository = $this->client->getRepository(self::$tmpdir . '/testrepo'); $fs = new Filesystem(); $fs->touch(self::$tmpdir . '/testrepo/original_file.txt'); @@ -354,6 +356,10 @@ class RepositoryTest extends PHPUnit_Framework_TestCase public function testIsGettingSymlinksWithinTreesOutput() { + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + $this->markTestSkipped('Unable to run on Windows'); + } + $repository = $this->client->getRepository(self::$tmpdir . '/testrepo'); $fs = new Filesystem(); $fs->touch(self::$tmpdir . '/testrepo/original_file.txt'); @@ -377,6 +383,11 @@ class RepositoryTest extends PHPUnit_Framework_TestCase public static function tearDownAfterClass() { $fs = new Filesystem(); - $fs->remove(self::$tmpdir); + + try { + $fs->remove(self::$tmpdir); + } catch (\Exception $e) { + // Ignore, file is not closed yet + } } }