[TASK] Create typo3temp directory in functional tests if missing 87/36587/4
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 2 Feb 2015 23:37:43 +0000 (00:37 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 3 Feb 2015 00:07:42 +0000 (01:07 +0100)
All functional tests are run in an encapsulated environment
within typo3temp. The functional bootstrap needs to take care
this directory exists.

Resolves: #64715
Releases: master
Change-Id: I07581db4d2c2cd9792dfde74ec9748c0824a549c
Reviewed-on: http://review.typo3.org/36587
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Build/FunctionalTestsBootstrap.php

index 68c54a1..c0f4ae4 100644 (file)
@@ -28,7 +28,8 @@ class FunctionalTestsBootstrap {
        public function bootstrapSystem() {
                $this->enableDisplayErrors()
                        ->loadClassFiles()
-                       ->defineOriginalRootPath();
+                       ->defineOriginalRootPath()
+                       ->createNecessaryDirectoriesInDocumentRoot();
        }
 
        /**
@@ -74,6 +75,37 @@ class FunctionalTestsBootstrap {
                return $this;
        }
 
+       /**
+        * Creates the following directories in the TYPO3 core:
+        * - typo3temp
+        *
+        * @return FunctionalTestsBootstrap fluent interface
+        */
+       protected function createNecessaryDirectoriesInDocumentRoot() {
+               $this->createDirectory(ORIGINAL_ROOT . 'typo3temp');
+
+               return $this;
+       }
+
+       /**
+        * Creates the directory $directory (recursively if required).
+        *
+        * If $directory already exists, this method is a no-op.
+        *
+        * @param string $directory absolute path of the directory to be created
+        * @return void
+        * @throws \RuntimeException
+        */
+       protected function createDirectory($directory) {
+               if (is_dir($directory)) {
+                       return;
+               }
+
+               if (!mkdir($directory, 0777, TRUE)) {
+                       throw new \RuntimeException('Directory "' . $directory . '" could not be created', 1404038665);
+               }
+       }
+
        /**
         * Returns the absolute path the TYPO3 document root.
         *