[TASK] Stabilize some tests if run as root
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 2 Sep 2012 11:17:16 +0000 (13:17 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 2 Sep 2012 11:43:39 +0000 (13:43 +0200)
GeneralUtility::fixPermissions has a bug if createGroup is set to the id
of the root group (0), and does not set the correct group. This is fixed
with a more sophisticated test in fixPermissions to allow 0 as
valid group. Default for createGroup is empty string, so it is now
checked with isset and strlen > 0 if chgrp() should be applied.

Additionally, the FAL test permissionsAreCorrectlyRetrieved is splitted
to four tests, and two of them are skipped if the test is run on linux
as root.

Change-Id: Icd3bb5808fef195da8394a8fd9c2797f9f01e9aa
Resolves: #40523
Releases: 6.0
Reviewed-on: http://review.typo3.org/14288
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
tests/Unit/t3lib/file/Driver/LocalDriverTest.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php

index 3e421c7..d710f88 100644 (file)
Binary files a/tests/Unit/t3lib/file/Driver/LocalDriverTest.php and b/tests/Unit/t3lib/file/Driver/LocalDriverTest.php differ
index 0f1f2fa..1bfa713 100644 (file)
@@ -2507,7 +2507,10 @@ Connection: close
                                        $result = @chmod($path, octdec($GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask']));
                                }
                                // Set createGroup if not empty
-                               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) {
+                               if (
+                                       isset($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'])
+                                       && strlen($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) > 0
+                               ) {
                                        // "@" is there because file is not necessarily OWNED by the user
                                        $changeGroupResult = @chgrp($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']);
                                        $result = $changeGroupResult ? $result : FALSE;
index de0e324..f70d05e 100644 (file)
@@ -2581,7 +2581,7 @@ class GeneralUtilityTest extends \tx_phpunit_testcase {
                clearstatcache();
                $resultFileGroup = filegroup($filename);
                unlink($filename);
-               $this->assertEquals($resultFileGroup, $currentGroupId);
+               $this->assertEquals($currentGroupId, $resultFileGroup);
        }
 
        /**