minor #16986 Fix Filesystem tests on Windows (WouterJ)

This PR was merged into the 2.3 branch.

Discussion
----------

Fix Filesystem tests on Windows

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16985
| License       | MIT
| Doc PR        | -

PHP's symlink function doesn't support relative symlinks on Windows. Running the filesystem tests in Windows resulted in 2 erroring tests because of this. After this PR, these tests are skipped on Windows.

The error wasn't catched by appveyor, as appveyor doesn't support symlinks at all.

Commits
-------

c376cf3 Fix FileSystem tests on Windows
This commit is contained in:
Fabien Potencier 2016-01-27 08:39:45 +01:00
commit 025f761798

View File

@ -884,7 +884,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
public function testMirrorCopiesLinkedDirectoryContents()
{
$this->markAsSkippedIfSymlinkIsMissing();
$this->markAsSkippedIfSymlinkIsMissing(true);
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
@ -904,7 +904,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
public function testMirrorCopiesRelativeLinkedContents()
{
$this->markAsSkippedIfSymlinkIsMissing();
$this->markAsSkippedIfSymlinkIsMissing(true);
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
$oldPath = getcwd();
@ -1028,7 +1028,10 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Unable to retrieve file group name');
}
private function markAsSkippedIfSymlinkIsMissing()
/**
* @param bool $relative Whether support for relative symlinks is required
*/
private function markAsSkippedIfSymlinkIsMissing($relative = false)
{
if (!function_exists('symlink')) {
$this->markTestSkipped('symlink is not supported');
@ -1037,6 +1040,11 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
if (false === self::$symlinkOnWindows) {
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
}
// https://bugs.php.net/bug.php?id=69473
if ($relative && '\\' === DIRECTORY_SEPARATOR && 1 === PHP_ZTS) {
$this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions');
}
}
private function markAsSkippedIfChmodIsMissing()