/** * setUp() = init DB etc. */ public function setUp() { $this->createDatabase(); // assuming that test-database can be created otherwise PHPUnit will skip the test $this->db = $this->useTestDatabase(); $this->importStdDB(); $ttContentExtension = tx_rnbase_util_TYPO3::isTYPO62OrHigher() ? 'frontend' : 'cms'; $this->importExtensions(array($ttContentExtension, 'devlog')); // devlog wieder aktivieren tx_mklib_tests_Util::disableDevlog('devlog', false); // logging aktivieren tx_mklib_tests_Util::storeExtConf(); tx_mklib_tests_Util::setExtConfVar('logDbHandler', 1); //logging zurücksetzen tx_mklib_util_testDB::clearLogCache(); //wir setzen noch das min Log Level auf -1 damit //systemeinstellungen nicht hereinspielen und alles geloggt wird tx_mklib_tests_Util::storeExtConf('devlog'); tx_mklib_tests_Util::setExtConfVar('minLogLevel', -1, 'devlog'); // Hooks leer machen da die aus anderen extensions stören könnten self::$hooks['rn_base']['util_db_do_insert_post'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rn_base']['util_db_do_insert_post']; self::$hooks['rn_base']['util_db_do_update_post'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rn_base']['util_db_do_update_post']; self::$hooks['rn_base']['util_db_do_delete_pre'] = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rn_base']['util_db_do_delete_pre']; $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rn_base']['util_db_do_insert_post'] = array(); $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rn_base']['util_db_do_update_post'] = array(); $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rn_base']['util_db_do_delete_pre'] = array(); }
/** * Add a wizard to column. * Usage: * * tx_rnbase::load('Tx_Rnbase_Util_TCA'); * $tca = new Tx_Rnbase_Util_TCA(); * $tca->addWizard($tcaTableArray, 'teams', 'add', 'wizard_add', array()); * * @param array &$tcaTable * @param string $colName * @param string $wizardName * @param string $moduleName * @param array $urlParams * @return void * @deprecated use getWizards() */ public function addWizard(&$tcaTable, $colName, $wizardName, $moduleName, $urlParams = array()) { if (\tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $tcaTable['columns'][$colName]['config']['wizards'][$wizardName]['module'] = array('name' => $moduleName, 'urlParameters' => $urlParams); } else { $tcaTable['columns'][$colName]['config']['wizards'][$wizardName]['script'] = $moduleName . '.php?' . http_build_query($urlParams); } }
/** * Merges two arrays recursively and "binary safe". * * @see \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(); * * @param array $original * @param array $overrule * @param boolean $addKeys * @param boolean $includeEmptyValues * @param boolean $enableUnsetFeature * @return void */ public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = TRUE, $includeEmptyValues = TRUE, $enableUnsetFeature = TRUE) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); return $original; } else { return t3lib_div::array_merge_recursive_overrule($original, $overrule, !$addKeys, $includeEmptyValues, $enableUnsetFeature); } }
/** * @return string */ public static function getDebugTrail() { tx_rnbase::load('tx_rnbase_util_TYPO3'); if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { return \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail(); } else { return t3lib_utility_Debug::debugTrail(); } }
/** * Forces the integer $theInt into the boundaries of $min and $max. If the $theInt is 'FALSE' then the $zeroValue is applied. * * @param integer $theInt Input value * @param integer $min Lower limit * @param integer $max Higher limit * @param integer $zeroValue Default value if input is FALSE. * @return integer The input value forced into the boundaries of $min and $max * @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8 - Use t3lib_utility_Math::forceIntegerInRange() instead */ public static function intInRange($theInt, $min, $max = 2000000000, $zeroValue = 0) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { return \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($theInt, $min, $max, $zeroValue); } elseif (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) { return t3lib_utility_Math::forceIntegerInRange($theInt, $min, $max, $zeroValue); } else { return t3lib_div::intInRange($theInt, $min, $max, $zeroValue); } }
/** * Returns the cache instance * * @param string $name * @return tx_rnbase_cache_ICache */ private static function getCacheImpl($name) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache62', $name); } elseif (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache60', $name); } elseif (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) { return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache46', $name); } return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache', $name); }
/** * Deaktiviert den Cache und den formtoken */ public static function removeVcAndFormToken(&$sString) { //cache und formtoken weg - diese sind ständig unterschiedlich //und deren Funktionalität sollte nicht hier getestet werden //auf der cli über cc ist der formtoken um 2 zeichen länger //den formToken gibt es erst ab TYPO3 4.5 $sVcAndFormTokenRegex = tx_rnbase_util_TYPO3::isTYPO45OrHigher() ? '/&vC=(.*?)&formToken=(.*?)\'\\)/' : '/&vC=(.*?)\'\\)/'; $sString = preg_replace($sVcAndFormTokenRegex, '\')', $sString); $moduleTokenRegex = tx_rnbase_util_TYPO3::isTYPO62OrHigher() ? '/%26moduleToken%3D(.*?)&/' : '//'; $sString = preg_replace($moduleTokenRegex, '&', $sString); $sString = str_replace('=1&', '=1\'', $sString); }
/** * Returns the cache * * @param string $name * @return tx_rnbase_cache_ICache */ private static function createTYPO3Cache($name) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $className = 'tx_rnbase_cache_TYPO3Cache62'; } elseif (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $className = 'tx_rnbase_cache_TYPO3Cache60'; } elseif (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) { $className = 'tx_rnbase_cache_TYPO3Cache46'; } else { $className = 'tx_rnbase_cache_TYPO3Cache'; } return tx_rnbase::makeInstance($className, $name); }
/** * @group unit * @dataProvider getExpectedParsedLinks */ public function testParseTemplateParsesLinksCorrect($template, $expectedParsedTemplate, $sortBy, $sortOrder) { $parameters = $this->getParameters(); $configurations = $this->getConfigurations(true); if ($sortBy) { $parameters->offsetSet('sortBy', $sortBy); } if ($sortOrder) { $parameters->offsetSet('sortOrder', $sortOrder); } $confId = 'myConfId.filter.'; $filter = tx_rnbase::makeInstance('tx_mklib_filter_Sorter', $parameters, $configurations, $confId); $fields = array(); $options = array(); $filter->init($fields, $options); $formatter = $configurations->getFormatter(); $parsedTemplate = $filter->parseTemplate($template, $formatter, $confId); // leerzeichen ab 6.2.3 nicht mehr vorhanden if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $expectedParsedTemplate = str_replace('" >', '">', $expectedParsedTemplate); } $this->assertEquals($expectedParsedTemplate, $parsedTemplate, 'link falsch'); }
/** * Wrapper method for GLOBALS[LANG]::JScharCode() or \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue() * Converts the input string to a JavaScript function returning the same string, but charset-safe. * Used for confirm and alert boxes where we must make sure that any string content * does not break the script AND want to make sure the charset is preserved. * * @param string $string Input string * @return string Input string with potential XSS code removed */ public static function quoteJSvalue($string) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $string = Tx_Rnbase_Utility_T3General::quoteJSvalue($string); } else { $string = $GLOBALS['LANG']->JScharCode($string); } return $string; }
public function addMessage($message, $title = '', $severity = 0, $storeInSession = FALSE) { $flashMessage = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getFlashMessageClass(), $message, $title, $severity, $storeInSession); if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { /** @var $flashMessageService FlashMessageService */ $flashMessageService = tx_rnbase::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); $flashMessageService->getMessageQueueByIdentifier()->enqueue($flashMessage); } else { t3lib_FlashMessageQueue::addMessage($flashMessage); } }
/** * Load a fullfilled TCE data array for a database record. * @param string $table * @param int $theUid * @param boolean $isNew */ public function getTCEFormArray($table, $theUid, $isNew = FALSE) { $transferDataClass = tx_rnbase_util_TYPO3::isTYPO62OrHigher() ? 'TYPO3\\CMS\\Backend\\Form\\DataPreprocessor' : 't3lib_transferData'; $trData = tx_rnbase::makeInstance($transferDataClass); $trData->addRawData = TRUE; $trData->fetchRecord($table, $theUid, $isNew ? 'new' : ''); // 'new' reset($trData->regTableItems_data); return $trData->regTableItems_data; }
public function testConvertContainedEmailsToMailToLinks() { $this->initSpamProtectionConfig(); $expectedLink = 'ein text mit einer mail <a href="javascript:linkTo_UnCryptMailto(\'ocknvq,ocknBjquv0fg\');" >mail​(at)​host.de</a> und noch einer <a href="javascript:linkTo_UnCryptMailto(\'ocknvq,cpqvjgtocknBjquv0fg\');" >anothermail​(at)​host.de</a>'; // leerzeichen ab 6.2.3 nicht mehr vorhanden if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $expectedLink = str_replace('" >', '">', $expectedLink); } $this->assertEquals($expectedLink, tx_mklib_util_String::convertContainedEmailsToMailToLinks('ein text mit einer mail mail@host.de und noch einer anothermail@host.de'), 'Mailto Links falsch'); }
/** * möglicherweise hängen geblibene tasks * @return array */ protected function getPossiblyFrozenTasks() { $selectFields = tx_rnbase_util_TYPO3::isTYPO62OrHigher() ? 'uid,serialized_task_object' : 'uid,classname'; return tx_rnbase_util_DB::doSelect($selectFields, 'tx_scheduler_task', array('enablefieldsoff' => true, 'where' => ' uid != ' . intval($this->taskUid) . ' AND LENGTH(serialized_executions) > 0 AND freezedetected = 0 AND lastexecution_time < ' . ($GLOBALS['EXEC_TIME'] - $this->getOption('threshold')))); }
/** * @group unit */ public function testDoActionCallsPageNotFoundHandlingIfPageNotFoundException() { if (!tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { self::markTestSkipped('Dieses Feature wird erst ab TYPO3 6.2 unterstützt'); } $controller = $this->getMock('tx_rnbase_controller', array('getTsfe')); $tsfe = $this->getMock(tx_rnbase_util_Typo3Classes::getTypoScriptFrontendControllerClass(), array('pageNotFoundAndExit'), array(), '', FALSE); $tsfe->expects(self::once())->method('pageNotFoundAndExit')->with('TYPO3\\CMS\\Core\\Error\\Http\\PageNotFoundException was thrown'); $controller->expects(self::once())->method('getTsfe')->will(self::returnValue($tsfe)); $parameters = $configurations = NULL; $controller->doAction('tx_rnbase_tests_action_throwPageNotFoundException', $parameters, $configurations); }
private function setTTOff() { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $GLOBALS['TT'] = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker(); } else { $GLOBALS['TT'] = new t3lib_timeTrackNull(); } $GLOBALS['TT']->start(); }
/** * @group unit */ public function testGetFailedTasks() { $databaseUtility = $this->getDatabaseUtility(); $selectFields = tx_rnbase_util_TYPO3::isTYPO62OrHigher() ? 'uid,serialized_task_object' : 'uid,classname'; $databaseUtility::staticExpects($this->once())->method('doSelect')->with($selectFields, 'tx_scheduler_task', array('enablefieldsoff' => TRUE, 'where' => 'uid != 123 AND ' . 'faildetected = 0 AND ' . 'lastexecution_failure != ""'))->will($this->returnValue(array('failedTasks'))); $scheduler = $this->getSchedulerByDbUtil($databaseUtility); $scheduler->setTaskUid(123); $this->assertEquals(array('failedTasks'), $this->callInaccessibleMethod($scheduler, 'getFailedTasks')); }
/** * @return void */ protected function loadAdditionalJsForDatePicker() { $this->getMod()->getDoc()->getPageRenderer()->loadPrototype(); $this->getMod()->getDoc()->getPageRenderer()->loadExtJS(); $this->getFormTool()->getTCEForm()->loadJavascriptLib('../t3lib/jsfunc.evalfield.js'); $this->getFormTool()->getTCEForm()->loadJavascriptLib('jsfunc.tbe_editor.js'); $typo3Settings = array('datePickerUSmode' => 0, 'dateFormat' => array('d-m-Y', 'G:i j-n-Y'), 'dateFormatUS' => array('n-j-Y', 'G:i n-j-Y')); $this->getMod()->getDoc()->getPageRenderer()->addInlineSettingArray('', $typo3Settings); if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $this->getMod()->getDoc()->getPageRenderer()->addJsFile("sysext/backend/Resources/Public/JavaScript/tceforms.js"); $this->getMod()->getDoc()->getPageRenderer()->addJsFile("js/extjs/ux/Ext.ux.DateTimePicker.js"); } else { $this->getFormTool()->getTCEForm()->loadJavascriptLib('../t3lib/js/extjs/ux/Ext.ux.DateTimePicker.js'); $this->getFormTool()->getTCEForm()->loadJavascriptLib('../t3lib/js/extjs/tceforms.js'); } }
/** * möglicherweise hängen geblibene tasks * @return array */ protected function getFailedTasks() { $selectFields = tx_rnbase_util_TYPO3::isTYPO62OrHigher() ? 'uid,serialized_task_object' : 'uid,classname'; $databaseUtility = $this->getDatabaseUtility(); return $databaseUtility::doSelect($selectFields, 'tx_scheduler_task', array('enablefieldsoff' => TRUE, 'where' => 'uid != ' . intval($this->taskUid) . ' AND ' . 'faildetected = 0 AND ' . 'lastexecution_failure != ""')); }