[BUGFIX] FunctionalTestCaseBootstrapUtility throws warnings on Windows 71/28371/2
authorNicole Cordes <typo3@cordes.co>
Thu, 13 Mar 2014 22:20:15 +0000 (23:20 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 13 Mar 2014 23:18:23 +0000 (00:18 +0100)
If the FunctionalTestCaseBootstrapUtility::removeInstance() tries to
delete an existing symlink to a folder, the function unlink() is used.
This leads to a warning on Windows systems because unlink can only
delete files and symlinks to files.
This patch adds a rmdir() call for symlinks which works for Windows
system as well.

Resolves: #56892
Releases: 6.2
Change-Id: I2de757daea89a65a0a631c7592287e16218c1452
Reviewed-on: https://review.typo3.org/28371
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Tests/FunctionalTestCaseBootstrapUtility.php

index e378ead..ad16ee7 100644 (file)
@@ -544,8 +544,12 @@ class FunctionalTestCaseBootstrapUtility {
                                        $OK = @rmdir($path);
                                }
                        } else {
-                               // If $path is a file, simply remove it
-                               $OK = unlink($path);
+                               // If $path is a symlink to a folder we need rmdir() on Windows systems
+                               if (!stristr(PHP_OS, 'darwin') && stristr(PHP_OS, 'win') && is_link($path) && is_dir($path . '/')) {
+                                       $OK = rmdir($path);
+                               } else {
+                                       $OK = unlink($path);
+                               }
                        }
                        clearstatcache();
                } elseif (is_link($path)) {