[Filesystem] Fixed tests on Windows

This commit is contained in:
Martin Hasoň 2012-08-10 12:42:04 +02:00
parent 237629ad64
commit 2dcb2d7d82

View File

@ -28,6 +28,23 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
*/
private $filesystem = null;
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 setUp()
{
$this->filesystem = new Filesystem();
@ -863,6 +880,10 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
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');
}
}
private function markAsSkippedIfChmodIsMissing()