Commit 2a061253 authored by Carsten  Rose's avatar Carsten Rose
Browse files

phpunit: fix problems. All tests successful.

parent 21711130
Pipeline #1222 passed with stage
in 1 minute and 47 seconds
......@@ -525,11 +525,15 @@ After parsing the configuration, the following variables will be set automatical
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| Keyword | Description |
+===============================+====================================================================================================================================+
| dbNameData | Use this to get name of the configured 'data'-database. '{{dbNameData:Y}} |
| dbNameData | Name of the 'data'-database. '{{dbNameData:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| dbNameQfq | Use this to get name of the configured 'QFQ'-database. '{{dbNameQfq:Y}} |
| dbNameQfq | Name of the 'QFQ'-database. '{{dbNameQfq:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| dbNameT3 | Use this to get name of the configured 'T3'-database. '{{dbNameT3:Y}} |
| dbNameT3 | Name of the 'T3'-database. '{{dbNameT3:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| SITE_PATH | Absolute path of the current T3 Instanz. '{{dbNameT3:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| EXT_PATH | Absolute path of the QFQ extension. '{{dbNameT3:Y}} |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
......
......@@ -85,7 +85,7 @@ class Config {
public static function readConfig($configPhp = '') {
$configT3qfq = array();
$configIni = '';
$configIni = ''; // outdated config file format
// Production Path to CONFIG_INI
$pathTypo3Conf = __DIR__ . '/../../../../..';
......@@ -94,8 +94,8 @@ class Config {
$pathTypo3Conf = __DIR__ . '/../../..';
}
// In case of missing $configIni
if (empty($configPhp)) {
// In case of missing $configPhp
if (empty($configPhp) ) {
# Read 'LocalConfiguration.php'
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][EXT_KEY])) {
......@@ -132,6 +132,7 @@ class Config {
if ($config === false) {
throw new qfq\UserFormException ("Error read file: " . $configPhp, ERROR_IO_READ_FILE);
}
// in case $configIni doesn't exist: just skip
if (!is_array($config)) {
$config = array();
......
......@@ -184,14 +184,14 @@ class Store {
*
* @param string $bodytext
* @param bool|false $phpUnit
* @param string $fileConfigIni
* @param string $qfqConfigPhpUnit
*
* @return null|Store
* @throws CodeException
* @throws UserFormException
* @throws UserReportException
*/
public static function getInstance($bodytext = '', $phpUnit = false, $fileConfigIni = '') {
public static function getInstance($bodytext = '', $phpUnit = false, $qfqConfigPhpUnit = '') {
if (defined('PHPUNIT_QFQ')) {
self::$phpUnit = true;
......@@ -199,10 +199,12 @@ class Store {
if (self::$phpUnit) {
if (self::$instance !== null && $fileConfigIni != '') {
// If $qfqConfigPhpUnit is given: clean STORE
// if (self::$instance !== null && $qfqConfigPhpUnit != '') {
if ($qfqConfigPhpUnit != '') {
if($fileConfigIni=='init'){
$fileConfigIni='';
if ($qfqConfigPhpUnit == 'init') {
$qfqConfigPhpUnit = '';
}
// fake to have a clean environment for the next test.
self::unsetStore(STORE_TYPO3);
......@@ -213,7 +215,7 @@ class Store {
}
// Testing different config files means initialize completely
if ($fileConfigIni != '') {
if ($qfqConfigPhpUnit != '') {
self::$instance = null;
}
}
......@@ -222,7 +224,7 @@ class Store {
if (self::$instance === null) {
// self::$phpUnit = $phpUnit;
self::$instance = new self($bodytext, $fileConfigIni);
self::$instance = new self($bodytext, $qfqConfigPhpUnit);
} else {
// Class Store seems to be persistent over multiple QFQ instantiation. Set bodytext again, with every new request (if bodytext is given).
if ($bodytext !== '') {
......
......@@ -326,73 +326,99 @@ class StoreTest extends TestCase {
*/
public function testConfigIniDefaultValues() {
$body = <<< EOT
; Comment
DB_1_USER = <DBUSER>
DB_1_SERVER = <DBSERVER>
DB_1_PASSWORD = <DBPW>
DB_1_NAME = <DB>
EOT;
$expect = [
SYSTEM_DB_1_USER => '<DBUSER>',
SYSTEM_DB_1_SERVER => '<DBSERVER>',
SYSTEM_DB_1_PASSWORD => '<DBPW>',
SYSTEM_DB_1_NAME => '<DB>',
];
$fileName = $this->createFile($body);
$this->store = Store::getInstance('', true, $fileName);
unlink($fileName);
$value = $this->store->getStore(STORE_SYSTEM);
// these values are different between runtime and PHPUnit environment: do not check
unset($value[SYSTEM_SQL_LOG]);
unset($value[SYSTEM_PATH_EXT]);
unset($value[SYSTEM_SITE_PATH]);
unset($value[SYSTEM_MAIL_LOG]);
unset($value[SYSTEM_SEND_E_MAIL]);
'DB_1_USER' => '<DBUSER>',
'DB_1_SERVER' => '<DBSERVER>',
'DB_1_PASSWORD' => '<DBPW>',
'DB_1_NAME' => '<DB>',
'documentation' => 'https://docs.typo3.org/typo3cms/drafts/github/T3DocumentationStarter/Public-Info-053/Manual.html',
'flagProduction' => 'yes',
'thumbnailDirSecure' => 'fileadmin/protected/qfqThumbnail',
'thumbnailDirPublic' => 'typo3temp/qfqThumbnail',
'cmdInkscape' => 'inkscape',
'cmdConvert' => 'convert',
'cmdWkhtmltopdf' => '/opt/wkhtmltox/bin/wkhtmltopdf',
'dateFormat' => 'yyyy-mm-dd',
'throwExceptionGeneralError' => 'no',
'qfqLog' => 'fileadmin/protected/log/qfq.log',
'sqlLogMode' => 'modify',
'showDebugInfo' => 'auto',
'init' => 'set names utf8',
'update' => 'auto',
'indexData' => '1',
'indexQfq' => '1',
'escapeTypeDefault' => 'm',
'securityVarsHoneypot' => 'email,username,password',
'securityAttackDelay' => 5,
'securityShowMessage' => '0',
'securityGetMaxLength' => 50,
'sessionTimeoutSeconds' => 1800,
'recordLockTimeoutSeconds' => 900,
'enterAsSubmit' => 1,
'editFormPage' => 'form',
'extraButtonInfoInline' => '<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>',
'extraButtonInfoBelow' => '<span class="glyphicon glyphicon-info-sign text-info" aria-hidden="true"></span>',
'extraButtonInfoClass' => '',
'saveButtonText' => '',
'saveButtonTooltip' => 'Save',
'saveButtonClass' => 'btn btn-default navbar-btn',
'saveButtonGlyphIcon' => 'glyphicon-ok',
'closeButtonText' => '',
'closeButtonTooltip' => 'Close',
'closeButtonClass' => 'btn btn-default navbar-btn',
'closeButtonGlyphIcon' => 'glyphicon-remove',
'deleteButtonText' => '',
'deleteButtonTooltip' => 'Delete',
'deleteButtonClass' => 'btn btn-default navbar-btn',
'deleteButtonGlyphIcon' => 'glyphicon-trash',
'newButtonText' => '',
'newButtonTooltip' => 'New',
'newButtonClass' => 'btn btn-default navbar-btn',
'newButtonGlyphIcon' => 'glyphicon-plus',
'bsColumns' => 'col-md-12 col-lg-10',
'bsLabelColumns' => 'col-md-3 col-lg-3',
'bsInputColumns' => 'col-md-6 col-lg-6',
'bsNoteColumns' => 'col-md-3 col-lg-3',
'data-required-error' => 'data required',
'data-match-error' => 'fields do not match',
'data-error' => 'error',
'classPill' => 'qfq-color-grey-1',
'classBody' => 'qfq-color-grey-2',
'buttonOnChangeClass' => 'btn-info alert-info',
'dbNameData' => '<DB>',
'dbNameQfq' => '<DB>',
// 'sqlLog' => '/var/www/html/crose/qfq/filea...ql.log',
// 'mailLog' => '/var/www/html/crose/qfq/filea...il.log',
// 'SITE_PATH' => '/var/www/html/crose/qfq',
// 'EXT_PATH' => '/var/www/html/crose/qfq/typo3...xt/qfq',
// 'sendEmail' => '/var/www/html/crose/qfq/typo3...dEmail',
];
// check default values
$this->assertEquals($expect, $value, "Retrieve system store.");
//
$body .= PHP_EOL . SYSTEM_FORM_BS_LABEL_COLUMNS . ' = 4';
$body .= PHP_EOL . SYSTEM_FORM_BS_INPUT_COLUMNS . ' = 5';
$body .= PHP_EOL . SYSTEM_FORM_BS_NOTE_COLUMNS . ' = 6';
$body .= PHP_EOL . SYSTEM_FORM_DATA_PATTERN_ERROR . ' = Pattern error';
$body .= PHP_EOL . SYSTEM_FORM_DATA_REQUIRED_ERROR . ' = Required error';
$body .= PHP_EOL . SYSTEM_FORM_DATA_MATCH_ERROR . ' = Fields do not match';
$body .= PHP_EOL . SYSTEM_FORM_DATA_ERROR . ' = Error';
$body .= PHP_EOL . SYSTEM_CSS_CLASS_QFQ_FORM . ' = main-class';
$body .= PHP_EOL . SYSTEM_CSS_CLASS_QFQ_FORM_PILL . ' = pill-class';
$body .= PHP_EOL . SYSTEM_CSS_CLASS_QFQ_FORM_BODY . ' = body-class';
$expect[F_BS_LABEL_COLUMNS] = '4';
$expect[F_BS_INPUT_COLUMNS] = '5';
$expect[F_BS_NOTE_COLUMNS] = '6';
$expect[F_FE_DATA_PATTERN_ERROR] = 'Pattern error';
$expect[F_FE_DATA_REQUIRED_ERROR] = 'Required error';
$expect[F_FE_DATA_MATCH_ERROR] = 'Fields do not match error';
$expect[F_FE_DATA_ERROR] = 'Error';
$expect[F_CLASS] = 'main-class';
$expect[F_CLASS_PILL] = 'pill-class';
$expect[F_CLASS_BODY] = 'body-class';
$body = <<< EOT
<?php
return [
// Comment
'DB_1_USER' => '<DBUSER>',
'DB_1_SERVER' => '<DBSERVER>',
'DB_1_PASSWORD' => '<DBPW>',
'DB_1_NAME' => '<DB>',
];
EOT;
$fileName = $this->createFile($body);
$this->store = Store::getInstance('', true, $fileName);
unlink($fileName);
$value = $this->store->getStore(STORE_SYSTEM);
// these values are different between runtime and PHPUnit environment: do not check
unset($value[SYSTEM_SQL_LOG]);
unset($value[SYSTEM_PATH_EXT]);
unset($value[SYSTEM_SITE_PATH]);
unset($value[SYSTEM_MAIL_LOG]);
unset($value[SYSTEM_SEND_E_MAIL]);
$config = $this->store->getStore(STORE_SYSTEM);
# The following won't be checked by content, cause they will change on different installations.
foreach ([ TYPO3_SQL_LOG, SYSTEM_MAIL_LOG, SYSTEM_SITE_PATH, SYSTEM_PATH_EXT, SYSTEM_SEND_E_MAIL] as $key) {
$this->assertTrue(isset($config[$key]), "Missing default value for '$key' " );
unset ($config[$key]);
}
// check default values
$this->assertEquals($expect, $value, "Check explizit defined values.");
$this->assertEquals($expect, $config, "Retrieve system store.");
}
/**
......
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