merged branch hason/filesystem_tests (PR #5574)
Commits
-------
2dcb2d7
[Filesystem] Fixed tests on Windows
Discussion
----------
[2.1][Filesystem] Fixed tests on Windows
Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
This commit is contained in:
commit
bc59f6a4ff
@ -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()
|
||||
|
Reference in New Issue
Block a user