From 03b634d114d3a9da79813e6950d9ea7017732dcb Mon Sep 17 00:00:00 2001 From: hakre Date: Thu, 19 Mar 2015 14:42:13 +0100 Subject: [PATCH] Prevent fatal error on missing symlink() function in tests The testsuite didn't run through for me because the php symlink() function was missing. It is only available on Windows Visa/Server 2008 or higher. This commit fixes the issue by checking if the method exists, and if not, marks the test as skipped because of a non-matching precondition. --- tests/Composer/Test/Util/FilesystemTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index a4d1255f9..8fc3a3642 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -188,6 +188,7 @@ class FilesystemTest extends TestCase @mkdir($basepath . "/real", 0777, true); touch($basepath . "/real/FILE"); + $this->skipTestIfSymlinkPhpFunctionIsMissing(); $result = @symlink($basepath . "/real", $symlinked); if (!$result) { @@ -216,6 +217,7 @@ class FilesystemTest extends TestCase $symlinked = $basepath . "/linked"; $symlinkedTrailingSlash = $symlinked . "/"; + $this->skipTestIfSymlinkPhpFunctionIsMissing(); $result = @symlink($basepath . "/real", $symlinked); if (!$result) { @@ -237,4 +239,11 @@ class FilesystemTest extends TestCase $this->assertFalse(file_exists($symlinkedTrailingSlash)); $this->assertFalse(file_exists($symlinked)); } + + private function skipTestIfSymlinkPhpFunctionIsMissing() + { + if (!function_exists('symlink')) { + $this->markTestSkipped('The php symlink() function for symbolic links is not available on this platform'); + } + } }