[TASK] Extend functional tests with creation of additional folders 79/27779/4
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Fri, 21 Feb 2014 17:32:41 +0000 (18:32 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 5 Mar 2014 21:18:00 +0000 (22:18 +0100)
Extends the functional tests with the possibility to create additional
folders inside the TYPO3 CMS test instance created within typo3temp.

Resolves: #56194
Releases: 6.2
Change-Id: I3271b3877fc953a2d876e56fc18af823d2e2a609
Reviewed-on: https://review.typo3.org/27779
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Bernhard Kraft
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/core/Tests/FunctionalTestCase.php
typo3/sysext/core/Tests/FunctionalTestCaseBootstrapUtility.php

index 5d52635..a558e2f 100644 (file)
@@ -137,6 +137,32 @@ abstract class FunctionalTestCase extends BaseTestCase {
        protected $configurationToUseInTestInstance = array();
 
        /**
+        * Array of folders that should be created inside the test instance document root.
+        *
+        * This property will stay empty in this abstract, so it is possible
+        * to just overwrite it in extending classes. Path noted here will
+        * be linked for every test of a test case and it is not possible to change
+        * the list of folders between single tests of a test case.
+        *
+        * Per default the following folder are created
+        * /fileadmin
+        * /typo3temp
+        * /typo3conf
+        * /typo3conf/ext
+        * /uploads
+        *
+        * To create additional folders add the paths to this array. Given paths are expected to be
+        * relative to the test instance root and have to begin with a slash. Example:
+        *
+        * array(
+        *   'fileadmin/user_upload'
+        * );
+        *
+        * @var array
+        */
+       protected $additionalFoldersToCreate = array();
+
+       /**
         * Private utility class used in setUp() and tearDown(). Do NOT use in test cases!
         *
         * @var \TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility
@@ -167,7 +193,8 @@ abstract class FunctionalTestCase extends BaseTestCase {
                        $this->coreExtensionsToLoad,
                        $this->testExtensionsToLoad,
                        $this->pathsToLinkInTestInstance,
-                       $this->configurationToUseInTestInstance
+                       $this->configurationToUseInTestInstance,
+                       $this->additionalFoldersToCreate
                );
        }
 
index 5ca1dc2..e378ead 100644 (file)
@@ -69,6 +69,18 @@ class FunctionalTestCaseBootstrapUtility {
        );
 
        /**
+        * @var array These folder are always created
+        */
+       protected $defaultFoldersToCreate = array(
+               '',
+               '/fileadmin',
+               '/typo3temp',
+               '/typo3conf',
+               '/typo3conf/ext',
+               '/uploads'
+       );
+
+       /**
         * Set up creates a test instance and database.
         *
         * @param string $testCaseClassName Name of test case class
@@ -76,6 +88,7 @@ class FunctionalTestCaseBootstrapUtility {
         * @param array $testExtensionsToLoad Array of test extensions to load
         * @param array $pathsToLinkInTestInstance Array of source => destination path pairs to be linked
         * @param array $configurationToUse Array of TYPO3_CONF_VARS that need to be overridden
+        * @param array $additionalFoldersToCreate Array of folder paths to be created
         * @return string Path to TYPO3 CMS test installation for this test case
         */
        public function setUp(
@@ -83,12 +96,13 @@ class FunctionalTestCaseBootstrapUtility {
                array $coreExtensionsToLoad,
                array $testExtensionsToLoad,
                array $pathsToLinkInTestInstance,
-               array $configurationToUse
+               array $configurationToUse,
+               array $additionalFoldersToCreate
        ) {
                $this->setUpIdentifier($testCaseClassName);
                $this->setUpInstancePath();
                $this->removeOldInstanceIfExists();
-               $this->setUpInstanceDirectories();
+               $this->setUpInstanceDirectories($additionalFoldersToCreate);
                $this->setUpInstanceCoreLinks();
                $this->linkTestExtensionsToInstance($testExtensionsToLoad);
                $this->linkPathsInTestInstance($pathsToLinkInTestInstance);
@@ -157,18 +171,12 @@ class FunctionalTestCaseBootstrapUtility {
        /**
         * Create folder structure of test instance.
         *
+        * @param array $additionalFoldersToCreate Array of additional folders to be created
         * @throws Exception
         * @return void
         */
-       protected function setUpInstanceDirectories() {
-               $foldersToCreate = array(
-                       '',
-                       '/fileadmin',
-                       '/typo3temp',
-                       '/typo3conf',
-                       '/typo3conf/ext',
-                       '/uploads'
-               );
+       protected function setUpInstanceDirectories(array $additionalFoldersToCreate = array()) {
+               $foldersToCreate = array_merge($this->defaultFoldersToCreate, $additionalFoldersToCreate);
                foreach ($foldersToCreate as $folder) {
                        $success = mkdir($this->instancePath . $folder);
                        if (!$success) {