Fixed bug #16849: [Unit tests] fixPermissions* tests rely on availability of posix_ge...
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 29 Dec 2010 22:03:30 +0000 (22:03 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 29 Dec 2010 22:03:30 +0000 (22:03 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9963 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/t3lib_divTest.php

index c595e91..a6caa04 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-12-29  Christian Kuuhn  <lolli@schwarzbuch>
 
+       * Fixed bug #16849: [Unit tests] fixPermissions* tests rely on availability of posix_getegid() (Thanks to Steffen Gebert)
        * Fixed bug #11286: Caching of pagesections uses superfluos serialize() call (Thanks to Rupert Germann)
 
 2010-12-28  Christian Kuuhn  <lolli@schwarzbuch>
index 7779bcd..d9b288b 100644 (file)
@@ -1603,6 +1603,32 @@ class t3lib_divTest extends tx_phpunit_testcase {
        // Tests concerning fixPermissions
        ///////////////////////////////
 
+       /**
+        * @test
+        */
+       public function fixPermissionsCorrectlySetsGroup() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('fixPermissionsCorrectlySetsGroupOwnerOfFile() tests not available on Windows');
+               }
+               if (!function_exists('posix_getegid')) {
+                       $this->markTestSkipped('Function posix_getegid() not available, fixPermissionsCorrectlySetsGroupOwnerOfFile() tests skipped');
+               }
+
+                       // Create and prepare test file
+               $filename = PATH_site . 'typo3temp/' . uniqid('test_');
+               t3lib_div::writeFileToTypo3tempDir($filename, '42');
+
+                       // Set target group and run method
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
+               $fixPermissionsResult = t3lib_div::fixPermissions($filename);
+
+               clearstatcache();
+               $resultFileGroup = filegroup($filename);
+               unlink($filename);
+
+               $this->assertEquals($resultFileGroup, posix_getegid());
+       }
+
        /**
         * @test
         */
@@ -1618,19 +1644,16 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($filename);
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
-               $resultFileGroup = filegroup($filename);
                unlink($filename);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultFilePermissions, '0660');
-               $this->assertEquals($resultFileGroup, posix_getegid());
        }
 
        /**
@@ -1648,19 +1671,16 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($filename);
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
-               $resultFileGroup = filegroup($filename);
                unlink($filename);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultFilePermissions, '0660');
-               $this->assertEquals($resultFileGroup, posix_getegid());
        }
 
        /**
@@ -1678,19 +1698,16 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '0770';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($directory . '/');
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
-               $resultDirectoryGroup = filegroup($directory);
                t3lib_div::rmdir($directory);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultDirectoryPermissions, '0770');
-               $this->assertEquals($resultDirectoryGroup, posix_getegid());
        }
 
        /**
@@ -1708,19 +1725,16 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '0770';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($directory);
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
-               $resultDirectoryGroup = filegroup($directory);
                t3lib_div::rmdir($directory);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultDirectoryPermissions, '0770');
-               $this->assertEquals($resultDirectoryGroup, posix_getegid());
        }
 
        /**
@@ -1754,25 +1768,17 @@ class t3lib_divTest extends tx_phpunit_testcase {
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
                $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '0770';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($baseDirectory, TRUE);
 
                        // Get actual permissions
                clearstatcache();
                $resultBaseDirectoryPermissions = substr(decoct(fileperms($baseDirectory)), 1);
-               $resultBaseDirectoryGroup = filegroup($baseDirectory);
                $resultBaseFilePermissions = substr(decoct(fileperms($baseDirectory . '/file')), 2);
-               $resultBaseFileGroup = filegroup($baseDirectory . '/file');
                $resultFooDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/foo')), 1);
-               $resultFooDirectoryGroup = filegroup($baseDirectory . '/foo');
                $resultFooFilePermissions = substr(decoct(fileperms($baseDirectory . '/foo/file')), 2);
-               $resultFooFileGroup = filegroup($baseDirectory . '/foo/file');
                $resultBarDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/.bar')), 1);
-               $resultBarDirectoryGroup = filegroup($baseDirectory . '/.bar');
                $resultBarFilePermissions = substr(decoct(fileperms($baseDirectory . '/.bar/.file')), 2);
-               $resultBarFileGroup = filegroup($baseDirectory . '/.bar/.file');
                $resultBarFile2Permissions = substr(decoct(fileperms($baseDirectory . '/.bar/..file2')), 2);
-               $resultBarFile2Group = filegroup($baseDirectory . '/.bar/..file2');
 
                        // Clean up
                unlink($baseDirectory . '/file');
@@ -1786,19 +1792,12 @@ class t3lib_divTest extends tx_phpunit_testcase {
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultBaseDirectoryPermissions, '0770');
-               $this->assertEquals($resultBaseDirectoryGroup, posix_getegid());
                $this->assertEquals($resultBaseFilePermissions, '0660');
-               $this->assertEquals($resultBaseFileGroup, posix_getegid());
                $this->assertEquals($resultFooDirectoryPermissions, '0770');
-               $this->assertEquals($resultFooDirectoryGroup, posix_getegid());
                $this->assertEquals($resultFooFilePermissions, '0660');
-               $this->assertEquals($resultFooFileGroup, posix_getegid());
                $this->assertEquals($resultBarDirectoryPermissions, '0770');
-               $this->assertEquals($resultBarDirectoryGroup, posix_getegid());
                $this->assertEquals($resultBarFilePermissions, '0660');
-               $this->assertEquals($resultBarFileGroup, posix_getegid());
                $this->assertEquals($resultBarFile2Permissions, '0660');
-               $this->assertEquals($resultBarFile2Group, posix_getegid());
        }
 
        /**
@@ -1825,7 +1824,6 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Test if everything was ok
                $this->assertFalse($fixPermissionsResult);
-               $this->assertEquals($resultFilePermissions, '0742');
        }