From 370f2abc5589ba7569ed4ea74015164c1a986e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Fri, 10 Aug 2012 12:42:04 +0200 Subject: [PATCH] [Filesystem] Fixed tests on Windows --- Tests/FilesystemTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Tests/FilesystemTest.php b/Tests/FilesystemTest.php index 07a9dcdfc5..d7f622f42e 100644 --- a/Tests/FilesystemTest.php +++ b/Tests/FilesystemTest.php @@ -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 @@ 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'); + } } private function markAsSkippedIfChmodIsMissing()