[BUGFIX] Skip some permissions tests if run as root 47/19547/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 3 Apr 2013 16:31:21 +0000 (18:31 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 3 Apr 2013 16:41:19 +0000 (18:41 +0200)
Some tests in the configuration manager test something is not
writable by manipulating the permissions on the target removing
the w flag. Those tests fail if the suite is run as user root,
this user is always allowed to write. Tests are skipped if run
as root now.

Change-Id: I81d740d7c112df548cf70c76673d433b8f1ff168
Resolves: #46895
Related: #46854
Releases: 6.1
Reviewed-on: https://review.typo3.org/19547
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php

index 3427acf..e2ce155 100644 (file)
@@ -295,7 +295,9 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function canWriteConfigurationReturnsFalseIfDirectoryIsNotWritable() {
-               if (TYPO3_OS == 'WIN') {
+               if (function_exists('posix_getegid') && posix_getegid() === 0) {
+                       $this->markTestSkipped('Test skipped if run on linux as root');
+               } elseif (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('Not available on Windows');
                }
                /** @var $fixture \TYPO3\CMS\Core\Configuration\ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
@@ -321,7 +323,9 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function canWriteConfigurationReturnsFalseIfLocalConfigurationFileIsNotWritable() {
-               if (TYPO3_OS == 'WIN') {
+               if (function_exists('posix_getegid') && posix_getegid() === 0) {
+                       $this->markTestSkipped('Test skipped if run on linux as root');
+               } elseif (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('Not available on Windows');
                }
                /** @var $fixture \TYPO3\CMS\Core\Configuration\ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
@@ -347,7 +351,9 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function canWriteConfigurationReturnsFalseIfLocalconfFileIsNotWritable() {
-               if (TYPO3_OS == 'WIN') {
+               if (function_exists('posix_getegid') && posix_getegid() === 0) {
+                       $this->markTestSkipped('Test skipped if run on linux as root');
+               } elseif (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('Not available on Windows');
                }
                /** @var $fixture \TYPO3\CMS\Core\Configuration\ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */