[CLEANUP] Move test file deletion into UnitTestCase class 59/31359/6
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 5 Jul 2014 16:58:34 +0000 (18:58 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 14 Sep 2014 11:25:42 +0000 (13:25 +0200)
In order to unify removal of files and directories created by unit
tests, the basic UnitTestCase class get a property to register
created files and directories. Removing those files is
implemented in tearDown().

Tests now just need to add created files to $this->testFilesToDelete
to get the automatically cleaned up after test run. The method is
constructed to only remove stuff within typo3conf/ext and typo3temp
to reduce the risk of removing too, it throws an exception if this
rule is not followed.

Change-Id: Ibca2b3a006432f2335fff8f0b0c05c62e363878c
Resolves: #60123
Releases: 6.3
Reviewed-on: http://review.typo3.org/31359
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
18 files changed:
typo3/sysext/backend/Tests/Unit/Utility/IconUtilityTest.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Documentation/Changelog/master/Feature-60123-UnitTestCaseRemovesTestFiles.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php
typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
typo3/sysext/core/Tests/Unit/TypoScript/TemplateServiceTest.php
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/core/Tests/UnitTestCase.php
typo3/sysext/dbal/Tests/Unit/Database/DatabaseConnectionTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/FileHandlingUtilityTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php
typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php
typo3/sysext/install/Tests/Unit/FolderStructure/AbstractNodeTest.php
typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php
typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php
typo3/sysext/install/Tests/Unit/FolderStructure/LinkNodeTest.php
typo3/sysext/install/Tests/Unit/FolderStructure/RootNodeTest.php

index 868e39e..369b353 100644 (file)
@@ -110,12 +110,12 @@ class IconUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                // Create image resource, determine target filename, fake target permission, run method and clean up
                $fixtureGifRessource = imagecreatefromgif($fixtureGifFile);
                $targetFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.gif';
+               $this->testFilesToDelete[] = $targetFilename;
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
                $subject = $this->subject;
                $subject::imagemake($fixtureGifRessource, $targetFilename);
                clearstatcache();
                $resultFilePermissions = substr(decoct(fileperms($targetFilename)), 2);
-               \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($targetFilename);
                $this->assertEquals($resultFilePermissions, '0777');
        }
 
index c43f673..f2425a0 100644 (file)
@@ -5094,7 +5094,7 @@ Connection: close
                                require_once ExtensionManagementUtility::extPath('core') . 'Classes/Locking/Locker.php';
                        }
                        // Write a longer message to the deprecation log
-                       $destination = self::getDeprecationLogFileName();
+                       $destination = static::getDeprecationLogFileName();
                        $file = @fopen($destination, 'a');
                        if ($file) {
                                @fwrite($file, ($date . $msg . LF));
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-60123-UnitTestCaseRemovesTestFiles.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-60123-UnitTestCaseRemovesTestFiles.rst
new file mode 100644 (file)
index 0000000..6c597c5
--- /dev/null
@@ -0,0 +1,17 @@
+========================================================
+Feature: #60123 - Unit base test case removes test files
+========================================================
+
+Description
+===========
+
+Some unit tests need to create test files or directories to check the system
+under test. Those files should be removed again.
+A test can now register absolute file paths in $this->testFilesToDelete, and
+the generic tearDown() method will then remove them. Only files, links and directories
+within typo3temp/ are allowed.
+
+Impact
+======
+
+This allows tests to clean up the environment without leaving obsolete test files behind.
\ No newline at end of file
index 3c4ae26..db9d2d8 100644 (file)
@@ -22,12 +22,6 @@ namespace TYPO3\CMS\Core\Tests\Unit\Configuration;
 class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * Absolute path to files that must be removed
-        * after a test - handled in tearDown
-        */
-       protected $testFilesToDelete = array();
-
-       /**
         * @var \TYPO3\CMS\Core\Configuration\ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject
         */
        protected $fixture;
@@ -42,16 +36,6 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
-        * Tear down test case
-        */
-       public function tearDown() {
-               foreach ($this->testFilesToDelete as $absoluteFileName) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::unlink_tempfile($absoluteFileName);
-               }
-               parent::tearDown();
-       }
-
-       /**
         * @param array $methods
         */
        protected function createFixtureWithMockedMethods(array $methods) {
@@ -446,6 +430,7 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $result = $fixture->canWriteConfiguration();
 
                $this->assertTrue($result);
+               $this->testFilesToDelete[] = $absoluteDirectory;
        }
 
        /**
index dcd90bc..99a3c1d 100644 (file)
@@ -794,6 +794,7 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
                ));
                $fixture = $this->createDriverFixture();
                $filePath = GeneralUtility::fixWindowsFilePath($fixture->_call('copyFileToTemporaryPath', '/someDir/someFile'));
+               $this->testFilesToDelete[] = $filePath;
                $this->assertContains('/typo3temp/', $filePath);
                $this->assertEquals($fileContents, file_get_contents($filePath));
        }
index a8bc9ce..226d090 100644 (file)
@@ -24,13 +24,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 class TemplateServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * Enable backup of global and system variables
-        *
-        * @var boolean
-        */
-       protected $backupGlobals = TRUE;
-
-       /**
         * @var \TYPO3\CMS\Core\TypoScript\TemplateService
         */
        protected $templateService;
index faa2684..5ded17d 100644 (file)
@@ -31,14 +31,6 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        protected $singletonInstances = array();
 
        /**
-        * Absolute path to files that must be removed
-        * after a test - handled in tearDown
-        *
-        * @TODO : Check if the tests can use vfs:// instead
-        */
-       protected $testFilesToDelete = array();
-
-       /**
         * @var \TYPO3\CMS\Core\Package\PackageManager
         */
        protected $backUpPackageManager;
@@ -46,19 +38,12 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
        public function setUp() {
                $this->singletonInstances = GeneralUtility::getSingletonInstances();
                $this->createAccessibleProxyClass();
-               $this->testFilesToDelete = array();
                $this->backUpPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
                $this->singletonInstances = GeneralUtility::getSingletonInstances();
        }
 
        public function tearDown() {
                ExtensionManagementUtility::clearExtensionKeyMap();
-               foreach ($this->testFilesToDelete as $absoluteFileName) {
-                       GeneralUtility::unlink_tempfile($absoluteFileName);
-               }
-               if (file_exists(PATH_site . 'typo3temp/test_ext/')) {
-                       GeneralUtility::rmdir(PATH_site . 'typo3temp/test_ext/', TRUE);
-               }
                ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backUpPackageManager);
                ExtensionManagementUtilityAccessibleProxy::setCacheManager(NULL);
                $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($this->backUpPackageManager);
@@ -127,8 +112,9 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         * @return object
         */
        protected function createMockPackageManagerWithMockPackage($packageKey, $packageMethods = array('getPackagePath', 'getPackageKey')) {
-               $packagePath = PATH_site . 'typo3temp/test_ext/' . $packageKey . '/';
+               $packagePath = PATH_site . 'typo3temp/' . $packageKey . '/';
                GeneralUtility::mkdir_deep($packagePath);
+               $this->testFilesToDelete[] = $packagePath;
                $package = $this->getMockBuilder('TYPO3\\CMS\\Core\\Package\\Package')
                                ->disableOriginalConstructor()
                                ->setMethods($packageMethods)
@@ -859,7 +845,6 @@ class ExtensionManagementUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                $extensionName = uniqid('foo');
                $packageManager = $this->createMockPackageManagerWithMockPackage($extensionName);
                $extLocalconfLocation = $packageManager->getPackage($extensionName)->getPackagePath() . 'ext_localconf.php';
-               $this->testFilesToDelete[] = $extLocalconfLocation;
                $uniqueStringInLocalconf = uniqid('foo');
                file_put_contents($extLocalconfLocation, "<?php\n\n" . $uniqueStringInLocalconf . "\n\n?>");
                $GLOBALS['TYPO3_LOADED_EXT'] = new \TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray($packageManager);
index 2e2e384..f89c4d4 100644 (file)
@@ -29,11 +29,6 @@ use \org\bovigo\vfs\vfsStreamWrapper;
 class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var array Files, directories and links to be deleted after a test
-        */
-       protected $testFilesToDelete = array();
-
-       /**
         * @var array A backup of registered singleton instances
         */
        protected $singletonInstances = array();
@@ -47,9 +42,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        public function tearDown() {
                Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-               foreach ($this->testFilesToDelete as $absoluteFileName) {
-                       Utility\GeneralUtility::rmdir($absoluteFileName, TRUE);
-               }
                parent::tearDown();
        }
 
@@ -2947,13 +2939,13 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                }
                // Create and prepare test file
                $filename = PATH_site . 'typo3temp/../typo3temp/' . uniqid('test_');
-               $this->testFilesToDelete[] = $filename;
                touch($filename);
                chmod($filename, 482);
                // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
                $fixPermissionsResult = Utility\GeneralUtility::fixPermissions($filename);
                clearstatcache();
+               $this->testFilesToDelete[] = $filename;
                $this->assertFalse($fixPermissionsResult);
        }
 
@@ -4288,16 +4280,26 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                if (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('deprecationLogFixesPermissionsOnLogFile() test not available on Windows.');
                }
-               // Fake all required settings and get an unique logfilename
-               $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = uniqid('test_');
-               $deprecationLogFilename = Utility\GeneralUtility::getDeprecationLogFileName();
+               // Create extending class and let getDeprecationLogFileName return something within typo3temp/
+               $className = uniqid('GeneralUtility');
+               /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Utility\GeneralUtility $subject */
+               $subject = __NAMESPACE__ . '\\' . $className;
+               eval(
+                       'namespace ' . __NAMESPACE__ . ';' .
+                       'class ' . $className . ' extends \\TYPO3\\CMS\\Core\\Utility\\GeneralUtility {' .
+                       '  static public function getDeprecationLogFileName() {' .
+                       '    return PATH_site . \'typo3temp/test_deprecation/test.log\';' .
+                       '  }' .
+                       '}'
+               );
+               $filePath = PATH_site . 'typo3temp/test_deprecation/';
+               @mkdir($filePath);
+               $this->testFilesToDelete[] = $filePath;
                $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = TRUE;
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
-               // Call method, get actual permissions and clean up
-               Utility\GeneralUtility::deprecationLog('foo');
-               $this->testFilesToDelete[] = $deprecationLogFilename;
+               $subject::deprecationLog('foo');
                clearstatcache();
-               $resultFilePermissions = substr(decoct(fileperms($deprecationLogFilename)), 2);
+               $resultFilePermissions = substr(decoct(fileperms($filePath . 'test.log')), 2);
                $this->assertEquals('0777', $resultFilePermissions);
        }
 
index d65f144..d5321e0 100644 (file)
@@ -13,6 +13,9 @@ namespace TYPO3\CMS\Core\Tests;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Base test case for unit tests.
@@ -33,6 +36,15 @@ abstract class UnitTestCase extends BaseTestCase {
        protected $backupGlobalsBlacklist = array('TYPO3_LOADED_EXT');
 
        /**
+        * Absolute path to files that should be removed after a test.
+        * Handled in tearDown. Tests can register here to get any files
+        * within typo3temp/ or typo3conf/ext cleaned up again.
+        *
+        * @var array
+        */
+       protected $testFilesToDelete = array();
+
+       /**
         * Unset all additional properties of test classes to help PHP
         * garbage collection. This reduces memory footprint with lots
         * of tests.
@@ -41,9 +53,11 @@ abstract class UnitTestCase extends BaseTestCase {
         * parent::tearDown() at the end. Unsetting of own properties
         * is not needed this way.
         *
+        * @throws \RuntimeException
         * @return void
         */
        protected function tearDown() {
+               // Unset properties of test classes to safe memory
                $reflection = new \ReflectionObject($this);
                foreach ($reflection->getProperties() as $property) {
                        $declaringClass = $property->getDeclaringClass()->getName();
@@ -58,5 +72,28 @@ abstract class UnitTestCase extends BaseTestCase {
                        }
                }
                unset($reflection);
+
+               // Delete registered test files and directories
+               foreach ($this->testFilesToDelete as $absoluteFileName) {
+                       $absoluteFileName = GeneralUtility::fixWindowsFilePath(PathUtility::getCanonicalPath($absoluteFileName));
+                       if (!GeneralUtility::validPathStr($absoluteFileName)) {
+                               throw new \RuntimeException('tearDown() cleanup: Filename contains illegal characters', 1410633087);
+                       }
+                       if (!StringUtility::beginsWith($absoluteFileName, PATH_site . 'typo3temp/')) {
+                               throw new \RuntimeException(
+                                       'tearDown() cleanup:  Files to delete must be within typo3temp/',
+                                       1410633412
+                               );
+                       }
+                       // file_exists returns false for links pointing to not existing targets, so handle links before next check.
+                       if (@is_link($absoluteFileName) || @is_file($absoluteFileName)) {
+                               unlink($absoluteFileName);
+                       } elseif(@is_dir($absoluteFileName)) {
+                               GeneralUtility::rmdir($absoluteFileName, TRUE);
+                       } else {
+                               throw new \RuntimeException('tearDown() cleanup: File, link or directory does not exist', 1410633510);
+                       }
+               }
+               $this->testFilesToDelete = array();
        }
 }
index d5171d5..751c222 100644 (file)
@@ -27,11 +27,6 @@ class DatabaseConnectionTest extends AbstractTestCase {
        protected $subject;
 
        /**
-        * @var array
-        */
-       protected $temporaryFiles = array();
-
-       /**
         * Set up
         */
        public function setUp() {
@@ -61,17 +56,6 @@ class DatabaseConnectionTest extends AbstractTestCase {
        }
 
        /**
-        * Tear down.
-        */
-       public function tearDown() {
-               // Delete temporary files
-               foreach ($this->temporaryFiles as $filename) {
-                       unlink($filename);
-               }
-               parent::tearDown();
-       }
-
-       /**
         * Creates a fake extension with a given table definition.
         *
         * @param string $tableDefinition SQL script to create the extension's tables
@@ -84,7 +68,7 @@ class DatabaseConnectionTest extends AbstractTestCase {
                if (!GeneralUtility::writeFile($ext_tables, $tableDefinition)) {
                        throw new \RuntimeException('Can\'t write temporary ext_tables file.');
                }
-               $this->temporaryFiles[] = $ext_tables;
+               $this->testFilesToDelete[] = $ext_tables;
                $GLOBALS['TYPO3_LOADED_EXT'] = array(
                        'test_dbal' => array(
                                'ext_tables.sql' => $ext_tables
index 8fdd0dd..b54ab3e 100644 (file)
@@ -26,28 +26,6 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        protected $fakedExtensions = array();
 
        /**
-        * @var array List of resources (files or empty directories) that need to be removed in tearDown() again
-        */
-       protected $resourcesToRemove = array();
-
-       /**
-        * @return void
-        */
-       public function tearDown() {
-               foreach ($this->fakedExtensions as $extension => $dummy) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir(PATH_site . 'typo3conf/ext/' . $extension, TRUE);
-               }
-               foreach ($this->resourcesToRemove as $resource) {
-                       if (file_exists($resource) && is_file($resource)) {
-                               unlink($resource);
-                       } elseif(file_exists($resource) && is_dir($resource)) {
-                               rmdir($resource);
-                       }
-               }
-               parent::tearDown();
-       }
-
-       /**
         * Creates a fake extension inside typo3temp/. No configuration is created,
         * just the folder
         *
@@ -56,8 +34,8 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        protected function createFakeExtension($extkeyOnly = FALSE) {
                $extKey = strtolower(uniqid('testing'));
-               $absExtPath = PATH_site . 'typo3conf/ext/' . $extKey . '/';
-               $relPath = 'typo3conf/ext/' . $extKey . '/';
+               $absExtPath = PATH_site . 'typo3temp/ext-' . $extKey . '/';
+               $relPath = 'typo3temp/ext-' . $extKey . '/';
                $this->fakedExtensions[$extKey] = array(
                        'siteRelPath' => $relPath,
                        'siteAbsPath' => $absExtPath
@@ -66,6 +44,7 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        return $extKey;
                }
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($absExtPath);
+               $this->testFilesToDelete[] = PATH_site . 'typo3temp/ext-' . $extKey;
                return $extKey;
        }
 
@@ -75,8 +54,13 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function makeAndClearExtensionDirRemovesExtensionDirIfAlreadyExists() {
                $extKey = $this->createFakeExtension();
-               $fileHandlerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\FileHandlingUtility', array('removeDirectory', 'addDirectory'), array(), '', FALSE);
-               $fileHandlerMock->expects($this->once())->method('removeDirectory')->with(PATH_site . 'typo3conf/ext/' . $extKey . '/');
+               $fileHandlerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\FileHandlingUtility', array('removeDirectory', 'addDirectory', 'getExtensionDir'), array(), '', FALSE);
+               $fileHandlerMock->expects($this->once())
+                       ->method('removeDirectory')
+                       ->with(PATH_site . 'typo3temp/ext-' . $extKey . '/');
+               $fileHandlerMock->expects($this->any())
+                       ->method('getExtensionDir')
+                       ->willReturn(PATH_site . 'typo3temp/ext-' . $extKey . '/');
                $fileHandlerMock->_call('makeAndClearExtensionDir', $extKey);
        }
 
@@ -130,8 +114,13 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function makeAndClearExtensionDirAddsDir() {
                $extKey = $this->createFakeExtension();
-               $fileHandlerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\FileHandlingUtility', array('removeDirectory', 'addDirectory'));
-               $fileHandlerMock->expects($this->once())->method('addDirectory')->with(PATH_site . 'typo3conf/ext/' . $extKey . '/');
+               $fileHandlerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\FileHandlingUtility', array('removeDirectory', 'addDirectory', 'getExtensionDir'));
+               $fileHandlerMock->expects($this->once())
+                       ->method('addDirectory')
+                       ->with(PATH_site . 'typo3temp/ext-' . $extKey . '/');
+               $fileHandlerMock->expects($this->any())
+                       ->method('getExtensionDir')
+                       ->willReturn(PATH_site . 'typo3temp/ext-' . $extKey . '/');
                $fileHandlerMock->_call('makeAndClearExtensionDir', $extKey);
        }
 
@@ -152,9 +141,9 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @return void
         */
        public function addDirectoryAddsDirectory() {
-               $extDirPath = $this->fakedExtensions[$this->createFakeExtension(TRUE)]['siteAbsPath'];
+               $extDirPath = PATH_site . '/typo3temp/' . uniqid('test-extensions-', TRUE);
+               $this->testFilesToDelete[] = $extDirPath;
                $fileHandlerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\FileHandlingUtility', array('dummy'));
-               $this->assertFalse(is_dir($extDirPath));
                $fileHandlerMock->_call('addDirectory', $extDirPath);
                $this->assertTrue(is_dir($extDirPath));
        }
@@ -164,9 +153,9 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @return void
         */
        public function removeDirectoryRemovesDirectory() {
-               $extDirPath = $this->fakedExtensions[$this->createFakeExtension()]['siteAbsPath'];
+               $extDirPath = PATH_site . '/typo3temp/' . uniqid('test-extensions-', TRUE);
+               @mkdir($extDirPath);
                $fileHandlerMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\FileHandlingUtility', array('dummy'));
-               $this->assertTrue(is_dir($extDirPath));
                $fileHandlerMock->_call('removeDirectory', $extDirPath);
                $this->assertFalse(is_dir($extDirPath));
        }
@@ -179,7 +168,7 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $absoluteSymlinkPath = PATH_site . 'typo3temp/' . uniqid('test_symlink_');
                $absoluteFilePath = PATH_site . 'typo3temp/' . uniqid('test_file_');
                touch($absoluteFilePath);
-               $this->resourcesToRemove[] = $absoluteFilePath;
+               $this->testFilesToDelete[] = $absoluteFilePath;
                symlink($absoluteFilePath, $absoluteSymlinkPath);
                $fileHandler = new \TYPO3\CMS\Extensionmanager\Utility\FileHandlingUtility();
                $fileHandler->removeDirectory($absoluteSymlinkPath);
@@ -198,8 +187,8 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                mkdir($absoluteDirectoryPath);
                touch($absoluteDirectoryPath . $relativeFilePath);
 
-               $this->resourcesToRemove[] = $absoluteDirectoryPath . $relativeFilePath;
-               $this->resourcesToRemove[] = $absoluteDirectoryPath;
+               $this->testFilesToDelete[] = $absoluteDirectoryPath . $relativeFilePath;
+               $this->testFilesToDelete[] = $absoluteDirectoryPath;
 
                symlink($absoluteDirectoryPath, $absoluteSymlinkPath);
 
@@ -567,7 +556,7 @@ class FileHandlingUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
                // File was created
                $this->assertTrue(file_exists($filename), 'Zip file not created');
-               $this->resourcesToRemove[] = $filename;
+               $this->testFilesToDelete[] = $filename;
 
                // Read archive and check its contents
                $archive = new \ZipArchive();
index a29801e..4132f99 100644 (file)
@@ -85,8 +85,8 @@ class InstallUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @return void
         */
        public function tearDown() {
-               foreach ($this->fakedExtensions as $extension => $dummy) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir(PATH_site . 'typo3temp/' . $extension, TRUE);
+               foreach ($this->fakedExtensions as $fakeExtkey => $fakeExtension) {
+                       $this->testFilesToDelete[] = PATH_site . 'typo3temp/' . $fakeExtkey;
                }
                parent::tearDown();
        }
index dafef50..5349723 100644 (file)
@@ -30,13 +30,6 @@ class IndexerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        protected $fixture = NULL;
 
        /**
-        * A name of the temporary file
-        *
-        * @var string
-        */
-       protected $temporaryFileName = '';
-
-       /**
         * Sets up the test
         */
        public function setUp() {
@@ -44,16 +37,6 @@ class IndexerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
-        * Explicitly clean up the indexer object to prevent any memory leaks
-        */
-       public function tearDown() {
-               if ($this->temporaryFileName) {
-                       @unlink($this->temporaryFileName);
-               }
-               parent::tearDown();
-       }
-
-       /**
         * @test
         */
        public function extractHyperLinksDoesNotReturnNonExistingLocalPath() {
@@ -67,14 +50,15 @@ class IndexerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function extractHyperLinksReturnsCorrectFileUsingT3Vars() {
-               $this->temporaryFileName = tempnam(sys_get_temp_dir(), 't3unit-');
+               $temporaryFileName = tempnam(PATH_site . 'typo3temp/', 't3unit-');
+               $this->testFilesToDelete[] = $temporaryFileName;
                $html = 'test <a href="testfile">test</a> test';
                $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = array(
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $this->temporaryFileName,
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $temporaryFileName,
                );
                $result = $this->fixture->extractHyperLinks($html);
                $this->assertEquals(1, count($result));
-               $this->assertEquals($this->temporaryFileName, $result[0]['localPath']);
+               $this->assertEquals($temporaryFileName, $result[0]['localPath']);
        }
 
        /**
index 19468ae..dd743a3 100644 (file)
@@ -20,23 +20,6 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
 class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var array Directories or files in typo3temp/ created during tests to delete afterwards
-        */
-       protected $testNodesToDelete = array();
-
-       /**
-        * Tear down
-        */
-       public function tearDown() {
-               foreach($this->testNodesToDelete as $node) {
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
-                       }
-               }
-               parent::tearDown();
-       }
-
-       /**
         * @test
         */
        public function getNameReturnsSetName() {
@@ -127,7 +110,7 @@ class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\AbstractNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertTrue($node->_call('exists'));
        }
@@ -144,7 +127,7 @@ class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $path = PATH_site . 'typo3temp/' . uniqid('link_');
                $target = PATH_site . 'typo3temp/' . uniqid('notExists_');
                symlink($target, $path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertTrue($node->_call('exists'));
        }
@@ -203,7 +186,7 @@ class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $subPath = $path . '/' . uniqid('dir_');
                mkdir($subPath);
                chmod($path, 02000);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
                $node->_set('targetPermission', '2770');
                $this->assertInstanceOf('TYPO3\\CMS\\Install\\Status\\NoticeStatus', $node->_call('fixPermission'));
@@ -235,7 +218,7 @@ class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $subPath = $path . '/' . uniqid('dir_');
                mkdir($subPath);
                chmod($path, 02000);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
                $node->_set('targetPermission', '2770');
                $this->assertInstanceOf('TYPO3\\CMS\\Install\\Status\\NoticeStatus', $node->_call('fixPermission'));
@@ -264,7 +247,7 @@ class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $subPath = $path . '/' . uniqid('dir_');
                mkdir($subPath);
                chmod($path, 02770);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->_set('targetPermission', '2770');
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
                $this->assertInstanceOf('TYPO3\\CMS\\Install\\Status\\OkStatus', $node->_call('fixPermission'));
@@ -305,7 +288,7 @@ class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\AbstractNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                chmod($path, 02775);
                clearstatcache();
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
@@ -323,7 +306,7 @@ class AbstractNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\AbstractNode', array('getAbsolutePath'), array(), '', FALSE);
                $file = PATH_site . 'typo3temp/' . uniqid('file_');
                touch($file);
-               $this->testNodesToDelete[] = $file;
+               $this->testFilesToDelete[] = $file;
                chmod($file, 0770);
                clearstatcache();
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($file));
index 3f4050e..76013a9 100644 (file)
@@ -20,23 +20,6 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
 class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var array Directories or files in typo3temp/ created during tests to delete afterwards
-        */
-       protected $testNodesToDelete = array();
-
-       /**
-        * Tear down
-        */
-       public function tearDown() {
-               foreach ($this->testNodesToDelete as $node) {
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
-                       }
-               }
-               parent::tearDown();
-       }
-
-       /**
         * @test
         * @expectedException \TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException
         */
@@ -185,7 +168,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch ($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isDirectory')->will($this->returnValue(FALSE));
@@ -211,7 +194,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch ($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
@@ -237,7 +220,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch ($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
@@ -263,7 +246,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch ($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
@@ -442,7 +425,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                /** @var $node \TYPO3\CMS\Install\FolderStructure\DirectoryNode|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_call('createDirectory');
@@ -456,7 +439,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                /** @var $node \TYPO3\CMS\Install\FolderStructure\DirectoryNode|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertInstanceOf('TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call('createDirectory'));
@@ -475,7 +458,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                mkdir($path);
                chmod($path, 02550);
                $subPath = $path . '/' . uniqid('dir_');
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
                $this->assertInstanceOf('TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call('createDirectory'));
@@ -576,7 +559,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('root_');
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertTrue($node->isWritable());
        }
@@ -595,7 +578,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('root_');
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                chmod($path, 02550);
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertFalse($node->isWritable());
@@ -609,7 +592,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertTrue($node->_call('isDirectory'));
        }
@@ -625,7 +608,7 @@ class DirectoryNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('root_');
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $link = uniqid('link_');
                $dir = uniqid('dir_');
                mkdir($path . '/' . $dir);
index 682cbbc..eae711a 100644 (file)
@@ -20,23 +20,6 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
 class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var array Directories or files in typo3temp/ created during tests to delete afterwards
-        */
-       protected $testNodesToDelete = array();
-
-       /**
-        * Tear down
-        */
-       public function tearDown() {
-               foreach ($this->testNodesToDelete as $node) {
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
-                       }
-               }
-               parent::tearDown();
-       }
-
-       /**
         * @test
         * @expectedException \TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException
         */
@@ -144,7 +127,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $targetFile = PATH_site . 'typo3temp/' . uniqid('test_');
                $targetContent = uniqid('content_');
                file_put_contents($targetFile, $targetContent);
-               $this->testNodesToDelete[] = $targetFile;
+               $this->testFilesToDelete[] = $targetFile;
                $structure = array(
                        'name' => 'foo',
                        'targetContentFile' => $targetFile,
@@ -244,7 +227,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isFile')->will($this->returnValue(FALSE));
@@ -271,7 +254,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isFile')->will($this->returnValue(TRUE));
@@ -298,7 +281,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch ($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isFile')->will($this->returnValue(TRUE));
@@ -325,7 +308,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isFile')->will($this->returnValue(TRUE));
@@ -352,7 +335,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isFile')->will($this->returnValue(TRUE));
@@ -548,7 +531,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                /** @var $node \TYPO3\CMS\Install\FolderStructure\FileNode|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertInstanceOf('TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call('createFile'));
@@ -561,7 +544,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                /** @var $node \TYPO3\CMS\Install\FolderStructure\FileNode|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_call('createFile');
@@ -581,7 +564,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                mkdir($path);
                chmod($path, 02550);
                $subPath = $path . '/' . uniqid('file_');
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
                $this->assertInstanceOf('TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call('createFile'));
@@ -596,7 +579,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                mkdir($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_call('isContentCorrect');
        }
@@ -609,7 +592,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_set('targetContent', NULL);
                $this->assertTrue($node->_call('isContentCorrect'));
@@ -624,7 +607,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
                $content = uniqid('content_');
                file_put_contents($path, $content);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_set('targetContent', $content);
                $this->assertTrue($node->_call('isContentCorrect'));
@@ -640,7 +623,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $content = uniqid('content1_');
                $targetContent = uniqid('content2_');
                file_put_contents($path, $content);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_set('targetContent', $targetContent);
                $this->assertFalse($node->_call('isContentCorrect'));
@@ -673,7 +656,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                mkdir($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_set('targetContent', 'foo');
                $node->_call('setContent');
@@ -688,7 +671,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->_set('targetContent', NULL);
                $node->_call('setContent');
@@ -702,7 +685,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath', 'getRelativePathBelowSiteRoot'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $targetContent = uniqid('content_');
                $node->_set('targetContent', $targetContent);
@@ -719,7 +702,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath', 'getRelativePathBelowSiteRoot'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $targetContent = uniqid('content_');
                $node->_set('targetContent', $targetContent);
@@ -743,7 +726,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $file = $dir . '/' . uniqid('file_');
                touch($file);
                chmod($file, 0440);
-               $this->testNodesToDelete[] = $dir;
+               $this->testFilesToDelete[] = $dir;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($file));
                $targetContent = uniqid('content_');
                $node->_set('targetContent', $targetContent);
@@ -758,7 +741,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertTrue($node->_call('isFile'));
        }
@@ -774,7 +757,7 @@ class FileNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array('getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('root_');
                \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir_deep($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $link = uniqid('link_');
                $file = uniqid('file_');
                touch($path . '/' . $file);
index 3c7ffea..3c0e7f6 100644 (file)
@@ -20,23 +20,6 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
 class LinkNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var array Directories or files in typo3temp/ created during tests to delete afterwards
-        */
-       protected $testNodesToDelete = array();
-
-       /**
-        * Tear down
-        */
-       public function tearDown() {
-               foreach ($this->testNodesToDelete as $node) {
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
-                       }
-               }
-               parent::tearDown();
-       }
-
-       /**
         * @test
         * @expectedException \TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException
         */
@@ -263,7 +246,7 @@ class LinkNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $path = PATH_site . 'typo3temp/' . uniqid('link_');
                $target = PATH_site . uniqid('linkTarget_');
                symlink($target, $path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertTrue($node->_call('isLink'));
@@ -280,7 +263,7 @@ class LinkNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
                $path = PATH_site . 'typo3temp/' . uniqid('file_');
                touch($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $this->assertFalse($node->_call('isLink'));
@@ -344,7 +327,7 @@ class LinkNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $path = PATH_site . 'typo3temp/' . uniqid('link_');
                $target = uniqid('linkTarget_');
                symlink($target, $path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                /** @var $node \TYPO3\CMS\Install\FolderStructure\LinkNode|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
                        array('exists', 'isLink', 'getTarget', 'getAbsolutePath'),
@@ -369,7 +352,7 @@ class LinkNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $path = PATH_site . 'typo3temp/' . uniqid('link_');
                $target = uniqid('linkTarget_');
                symlink($target, $path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                /** @var $node \TYPO3\CMS\Install\FolderStructure\LinkNode|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
                $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
                        array('exists', 'isLink', 'getTarget', 'getAbsolutePath'),
index 89c646a..10785a8 100644 (file)
@@ -20,23 +20,6 @@ namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
 class RootNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var array Directories or files in typo3temp/ created during tests to delete afterwards
-        */
-       protected $testNodesToDelete = array();
-
-       /**
-        * Tear down
-        */
-       public function tearDown() {
-               foreach ($this->testNodesToDelete as $node) {
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
-                               \TYPO3\CMS\Core\Utility\GeneralUtility::rmdir($node, TRUE);
-                       }
-               }
-               parent::tearDown();
-       }
-
-       /**
         * @test
         * @expectedException \TYPO3\CMS\Install\FolderStructure\Exception\RootNodeException
         */
@@ -193,7 +176,7 @@ class RootNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch ($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->once())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->once())->method('isDirectory')->will($this->returnValue(TRUE));
@@ -219,7 +202,7 @@ class RootNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
                $path = PATH_site . 'typo3temp/' . uniqid('dir_');
                touch ($path);
-               $this->testNodesToDelete[] = $path;
+               $this->testFilesToDelete[] = $path;
                $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
                $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
                $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));