Commit 67c857ad authored by Carsten  Rose's avatar Carsten Rose
Browse files

phpunit.xml: implement const 'PHPUNIT_QFQ'. Store.php: set self::$phpUnit on const 'PHPUNIT_QFQ'

parent 1af9cff9
Pipeline #1185 passed with stage
in 1 minute and 41 seconds
...@@ -193,7 +193,11 @@ class Store { ...@@ -193,7 +193,11 @@ class Store {
*/ */
public static function getInstance($bodytext = '', $phpUnit = false, $fileConfigIni = '') { public static function getInstance($bodytext = '', $phpUnit = false, $fileConfigIni = '') {
if ($phpUnit) { if (defined('PHPUNIT_QFQ')) {
self::$phpUnit = true;
}
if (self::$phpUnit) {
if (self::$instance !== null) { if (self::$instance !== null) {
// fake to have a clean environment for the next test. // fake to have a clean environment for the next test.
...@@ -212,7 +216,7 @@ class Store { ...@@ -212,7 +216,7 @@ class Store {
// Design Pattern: Singleton // Design Pattern: Singleton
if (self::$instance === null) { if (self::$instance === null) {
self::$phpUnit = $phpUnit; // self::$phpUnit = $phpUnit;
self::$instance = new self($bodytext, $fileConfigIni); self::$instance = new self($bodytext, $fileConfigIni);
} else { } else {
...@@ -239,6 +243,7 @@ class Store { ...@@ -239,6 +243,7 @@ class Store {
* @param array $config * @param array $config
* *
* @return array * @return array
* @throws CodeException
*/ */
private static function doSystemPath(array $config) { private static function doSystemPath(array $config) {
...@@ -246,8 +251,18 @@ class Store { ...@@ -246,8 +251,18 @@ class Store {
if (!isset($config[SYSTEM_PATH_EXT]) || $config[SYSTEM_PATH_EXT] === '' || $config[SYSTEM_PATH_EXT][0] !== '/') { if (!isset($config[SYSTEM_PATH_EXT]) || $config[SYSTEM_PATH_EXT] === '' || $config[SYSTEM_PATH_EXT][0] !== '/') {
$relExtDir = '/typo3conf/ext/' . EXT_KEY; $relExtDir = '/typo3conf/ext/' . EXT_KEY;
// If we are called through AJAX API (e.g. api/save.php), there is no TYPO3 environment. if (defined('PHPUNIT_QFQ')) {
if (isset($_SERVER['SCRIPT_FILENAME'])) { $cwd = getcwd();
$pos = strpos($cwd, '/typo3conf/');
if($pos==false){
throw new CodeException("Directory component '/typo3conf/' not found in '$cwd'", 1);
}
// this means phpUnit.
$config[SYSTEM_SITE_PATH] = substr($cwd, 0, $pos);
$config[SYSTEM_PATH_EXT] = $config[SYSTEM_SITE_PATH] . $relExtDir;
} else {
// If we are called through AJAX API (e.g. api/save.php), there is no TYPO3 environment.
$pos = strpos($_SERVER['SCRIPT_FILENAME'], $relExtDir); $pos = strpos($_SERVER['SCRIPT_FILENAME'], $relExtDir);
if ($pos === false && isset($GLOBALS['TYPO3_LOADED_EXT'][EXT_KEY]['ext_localconf.php'])) { if ($pos === false && isset($GLOBALS['TYPO3_LOADED_EXT'][EXT_KEY]['ext_localconf.php'])) {
...@@ -259,10 +274,6 @@ class Store { ...@@ -259,10 +274,6 @@ class Store {
$config[SYSTEM_PATH_EXT] = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos + strlen($relExtDir)); $config[SYSTEM_PATH_EXT] = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos + strlen($relExtDir));
$config[SYSTEM_SITE_PATH] = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos); $config[SYSTEM_SITE_PATH] = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
} }
} else {
// No $_SERVER >>this means phpUnit.
$config[SYSTEM_SITE_PATH] = getcwd();
$config[SYSTEM_PATH_EXT] = getcwd();
} }
} }
......
...@@ -11,5 +11,6 @@ ...@@ -11,5 +11,6 @@
</filter> </filter>
<php> <php>
<ini name='session.cookie_lifetime' value='259200' /> <ini name='session.cookie_lifetime' value='259200' />
<const name="PHPUNIT_QFQ" value="true"/>
</php> </php>
</phpunit> </phpunit>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment