[BUGFIX] Some unit tests fail in Core::LocalDriverTest
authorNicole Cordes <nicole@cordes.co>
Tue, 20 Nov 2012 00:30:28 +0000 (01:30 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Tue, 20 Nov 2012 18:34:36 +0000 (19:34 +0100)
Some tests fail on Windows systems. Mostly this is because of a missing
file and folder permission handling. Those tests have to be skipped.
Furthermore there is some path fixing needed in basic class.

Change-Id: Ib89e84539af2742dbb3a6e2f53ae5a0c121a0626
Fixes: #43126
Release: 6.0
Reviewed-on: http://review.typo3.org/16596
Reviewed-by: Oliver Klee
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php

index 9740214..61976eb 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace TYPO3\CMS\Core\Resource\Driver;
 <?php
 namespace TYPO3\CMS\Core\Resource\Driver;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /***************************************************************
  * Copyright notice
 
 /***************************************************************
  * Copyright notice
@@ -26,6 +27,7 @@ namespace TYPO3\CMS\Core\Resource\Driver;
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
  * Driver for the local file system
  *
 /**
  * Driver for the local file system
  *
@@ -398,7 +400,7 @@ class LocalDriver extends \TYPO3\CMS\Core\Resource\Driver\AbstractDriver {
                }
                $directoryEntries = array();
                while ($iterator->valid()) {
                }
                $directoryEntries = array();
                while ($iterator->valid()) {
-                       /** @var $entry SplFileInfo */
+                       /** @var $entry \SplFileInfo */
                        $entry = $iterator->current();
                        // skip non-files/non-folders, and empty entries
                        if (!$entry->isFile() && !$entry->isDir() || $entry->getFilename() == '') {
                        $entry = $iterator->current();
                        // skip non-files/non-folders, and empty entries
                        if (!$entry->isFile() && !$entry->isDir() || $entry->getFilename() == '') {
@@ -410,7 +412,7 @@ class LocalDriver extends \TYPO3\CMS\Core\Resource\Driver\AbstractDriver {
                                $iterator->next();
                                continue;
                        }
                                $iterator->next();
                                continue;
                        }
-                       $entryPath = substr($entry->getPathname(), strlen($path));
+                       $entryPath = GeneralUtility::fixWindowsFilePath(substr($entry->getPathname(), strlen($path)));
                        if ($entry->isDir()) {
                                $entryPath .= '/';
                        }
                        if ($entry->isDir()) {
                                $entryPath .= '/';
                        }
@@ -861,7 +863,7 @@ class LocalDriver extends \TYPO3\CMS\Core\Resource\Driver\AbstractDriver {
        public function renameFile(\TYPO3\CMS\Core\Resource\FileInterface $file, $newName) {
                // Makes sure the Path given as parameter is valid
                $newName = $this->sanitizeFileName($newName);
        public function renameFile(\TYPO3\CMS\Core\Resource\FileInterface $file, $newName) {
                // Makes sure the Path given as parameter is valid
                $newName = $this->sanitizeFileName($newName);
-               $newIdentifier = rtrim(dirname($file->getIdentifier()), '/') . '/' . $newName;
+               $newIdentifier = rtrim(GeneralUtility::fixWindowsFilePath(dirname($file->getIdentifier())), '/') . '/' . $newName;
                // The target should not exist already
                if ($this->fileExists($newIdentifier)) {
                        throw new \TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException('The target file already exists.', 1320291063);
                // The target should not exist already
                if ($this->fileExists($newIdentifier)) {
                        throw new \TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException('The target file already exists.', 1320291063);
@@ -901,7 +903,7 @@ class LocalDriver extends \TYPO3\CMS\Core\Resource\Driver\AbstractDriver {
                $newName = $this->sanitizeFileName($newName);
                $relativeSourcePath = $folder->getIdentifier();
                $sourcePath = $this->getAbsolutePath($relativeSourcePath);
                $newName = $this->sanitizeFileName($newName);
                $relativeSourcePath = $folder->getIdentifier();
                $sourcePath = $this->getAbsolutePath($relativeSourcePath);
-               $relativeTargetPath = rtrim(dirname($relativeSourcePath), '/') . '/' . $newName . '/';
+               $relativeTargetPath = rtrim(GeneralUtility::fixWindowsFilePath(dirname($relativeSourcePath)), '/') . '/' . $newName . '/';
                $targetPath = $this->getAbsolutePath($relativeTargetPath);
                // get all files and folders we are going to move, to have a map for updating later.
                $filesAndFolders = $this->getFileAndFoldernamesInPath($sourcePath, TRUE);
                $targetPath = $this->getAbsolutePath($relativeTargetPath);
                // get all files and folders we are going to move, to have a map for updating later.
                $filesAndFolders = $this->getFileAndFoldernamesInPath($sourcePath, TRUE);
index 15b8be8..685f718 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver;
 <?php
 namespace TYPO3\CMS\Core\Tests\Unit\Resource\Driver;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /***************************************************************
  *  Copyright notice
 
 /***************************************************************
  *  Copyright notice
@@ -972,7 +973,7 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
                        'basePath' => $this->getMountRootUrl()
                ));
                $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
                        'basePath' => $this->getMountRootUrl()
                ));
                $mockedFile = $this->getSimpleFileMock('/someDir/someFile');
-               $filePath = $fixture->copyFileToTemporaryPath($mockedFile);
+               $filePath = GeneralUtility::fixWindowsFilePath($fixture->copyFileToTemporaryPath($mockedFile));
                $this->assertContains('/typo3temp/', $filePath);
                $this->assertEquals($fileContents, file_get_contents($filePath));
        }
                $this->assertContains('/typo3temp/', $filePath);
                $this->assertEquals($fileContents, file_get_contents($filePath));
        }
@@ -995,6 +996,8 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
        public function permissionsAreCorrectlyRetrievedForForbiddenFile() {
                if (function_exists('posix_getegid') && posix_getegid() === 0) {
                        $this->markTestSkipped('Test skipped if run on linux as root');
        public function permissionsAreCorrectlyRetrievedForForbiddenFile() {
                if (function_exists('posix_getegid') && posix_getegid() === 0) {
                        $this->markTestSkipped('Test skipped if run on linux as root');
+               } elseif (TYPO3_OS === 'WIN') {
+                       $this->markTestSkipped('Test skipped if run on Windows system');
                }
                /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
                list($basedir, $fixture) = $this->prepareRealTestEnvironment();
                }
                /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
                list($basedir, $fixture) = $this->prepareRealTestEnvironment();
@@ -1022,6 +1025,8 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
        public function permissionsAreCorrectlyRetrievedForForbiddenFolder() {
                if (function_exists('posix_getegid') && posix_getegid() === 0) {
                        $this->markTestSkipped('Test skipped if run on linux as root');
        public function permissionsAreCorrectlyRetrievedForForbiddenFolder() {
                if (function_exists('posix_getegid') && posix_getegid() === 0) {
                        $this->markTestSkipped('Test skipped if run on linux as root');
+               } elseif (TYPO3_OS === 'WIN') {
+                       $this->markTestSkipped('Test skipped if run on Windows system');
                }
                /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
                list($basedir, $fixture) = $this->prepareRealTestEnvironment();
                }
                /** @var $fixture \TYPO3\CMS\Core\Resource\Driver\LocalDriver */
                list($basedir, $fixture) = $this->prepareRealTestEnvironment();
@@ -1086,6 +1091,9 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
         * @dataProvider getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider
         */
        public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser($group, $permissions, $expectedResult) {
         * @dataProvider getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser_dataProvider
         */
        public function getFilePermissionsReturnsCorrectPermissionsForFilesNotOwnedByCurrentUser($group, $permissions, $expectedResult) {
+               if (TYPO3_OS === 'WIN') {
+                       $this->markTestSkipped('Test skipped if run on Windows system');
+               }
                $this->addToMount(array(
                        'testfile' => 'asdfg'
                ));
                $this->addToMount(array(
                        'testfile' => 'asdfg'
                ));