diff --git a/README.md b/README.md index 957a431..3a610a5 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ $structure = $defaultSection->getStructure(); $this->assertTrue(is_array($structure['pages:1']['__contents']['tt_content:1'])); ``` +In case of using helhum/typo3-secure-web do not forget to set TYPO3_PATH_WEB to your web-dir folder + #### Structure The returned structure of a frontend request is an array with some information about your page and its children. @@ -203,3 +205,7 @@ Following links provide documentation and additional information about TYPO3 CMS - [Functional tests for dummies](https://de.slideshare.net/cpsitgmbh/functional-tests-for-dummies-65673214) Last but not least you may ask for further support in the Slack channel "[#cig-testing](https://typo3.slack.com/messages/cig-testing)". + +## helhum/typo3-secure-web compatibility + +In case of using helhum/typo3-secure-web you should set TYPO3_PATH_ROOT to your private dir, and TYPO3_PATH_WEB to the public one. diff --git a/src/TestingFramework/Bootstrap/AbstractBootstrap.php b/src/TestingFramework/Bootstrap/AbstractBootstrap.php index c5fdb99..9d3be88 100644 --- a/src/TestingFramework/Bootstrap/AbstractBootstrap.php +++ b/src/TestingFramework/Bootstrap/AbstractBootstrap.php @@ -81,6 +81,7 @@ public function bootstrapFunctionalTestSystem() $this->enableDisplayErrors(); $this->createNecessaryDirectoriesInDocumentRoot(); $this->defineOriginalRootPath(); + $this->defineOriginalWebPath(); } /** @@ -151,6 +152,27 @@ protected function defineOriginalRootPath() } } + /** + * Defines the constant ORIGINAL_WEB for the path to the web(public) TYPO3 root dir + * In case of using helhum/typo3-secure-web your private and public sources can have different root paths + * + * @return void + */ + protected function defineOriginalWebPath() + { + if (!defined('ORIGINAL_WEB')) { + /** @var string */ + define('ORIGINAL_WEB', $this->getPublicRootPath()); + } + + if (!file_exists(ORIGINAL_WEB . 'index.php')) { + $this->exitWithMessage( + 'Unable to determine path to entry script.' + . ' Please check your path or set an environment variable \'TYPO3_PATH_WEB\' to your public root path.' + ); + } + } + /** * Returns the absolute path to the TYPO3 document root * @@ -169,6 +191,24 @@ protected function getWebRoot() return rtrim(str_replace('\\', '/', $webRoot), '/') . '/'; } + /** + * Returns the absolute path to the TYPO3 public root dir + * + * @return string the TYPO3 public root using Unix path separators + */ + protected function getPublicRootPath() + { + if (getenv('TYPO3_PATH_WEB')) { + $publicRoot = getenv('TYPO3_PATH_WEB'); + } elseif (getenv('TYPO3_PATH_ROOT')) { + $publicRoot = getenv('TYPO3_PATH_ROOT'); + } else { + $publicRoot = getcwd(); + } + + return rtrim(str_replace('\\', '/', $publicRoot), '/') . '/'; + } + /** * Creates the directory $directory (recursively if required). * diff --git a/src/TestingFramework/TestSystem/AbstractTestSystem.php b/src/TestingFramework/TestSystem/AbstractTestSystem.php index d8c62ee..de7b0b8 100644 --- a/src/TestingFramework/TestSystem/AbstractTestSystem.php +++ b/src/TestingFramework/TestSystem/AbstractTestSystem.php @@ -307,7 +307,7 @@ protected function setUpSystemCoreLinks() { $linksToSet = [ ORIGINAL_ROOT . 'typo3' => $this->systemPath . 'typo3', - ORIGINAL_ROOT . 'index.php' => $this->systemPath . 'index.php', + ORIGINAL_WEB . 'index.php' => $this->systemPath . 'index.php', ]; foreach ($linksToSet as $from => $to) { if (!symlink($from, $to)) { @@ -337,11 +337,14 @@ protected function linkTestExtensionsToSystem(array $extensionPaths) ); } $destinationPath = $this->systemPath . 'typo3conf/ext/' . basename($absoluteExtensionPath); - if (!symlink($absoluteExtensionPath, $destinationPath)) { - throw new Exception( - 'Can not link extension folder: ' . $absoluteExtensionPath . ' to ' . $destinationPath, - 1376657142 - ); + + if (!file_exists($destinationPath)) { + if (!symlink($absoluteExtensionPath, $destinationPath)) { + throw new Exception( + 'Can not link extension folder: ' . $absoluteExtensionPath . ' to ' . $destinationPath, + 1376657142 + ); + } } } }