Skip to content

Commit 370f2ab

Browse files
committed
[Filesystem] Fixed tests on Windows
1 parent 57c95ad commit 370f2ab

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Tests/FilesystemTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
2828
*/
2929
private $filesystem = null;
3030

31+
private static $symlinkOnWindows = null;
32+
33+
public static function setUpBeforeClass()
34+
{
35+
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
36+
self::$symlinkOnWindows = true;
37+
$originDir = tempnam(sys_get_temp_dir(), 'sl');
38+
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
39+
if (true !== @symlink($originDir, $targetDir)) {
40+
$report = error_get_last();
41+
if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
42+
self::$symlinkOnWindows = false;
43+
}
44+
}
45+
}
46+
}
47+
3148
public function setUp()
3249
{
3350
$this->filesystem = new Filesystem();
@@ -863,6 +880,10 @@ private function markAsSkippedIfSymlinkIsMissing()
863880
if (!function_exists('symlink')) {
864881
$this->markTestSkipped('symlink is not supported');
865882
}
883+
884+
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false === self::$symlinkOnWindows) {
885+
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on windows');
886+
}
866887
}
867888

868889
private function markAsSkippedIfChmodIsMissing()

0 commit comments

Comments
 (0)