[TYPO3-dev]  Fake / simulate frontend environment ( TSFE )
    Elmar Hinz 
    elmar07 at googlemail.com
       
    Wed Nov 21 00:11:41 CET 2007
    
    
  
Hi,
by request of Dmitry I start this topic as a new thread, to make it the more
easy findable within the list.
How to quickly fake a FE in the BE?
Here is a very, very official solution from Robert, found in his extension
t3unit, now followed by the extension phpunit:
http://typo3.org/extensions/repository/view/phpunit/3.1.15/info/mod1%252Findex.php/
   /**
     * Roughly simulates the frontend although being in the backend.
     *
     * @return    void
     * @todo    This is a quick hack, needs proper implementation
     */
    protected function simulateFrontendEnviroment() {
        global $TSFE, $TYPO3_CONF_VARS;
            // FIXME: Currently bad workaround which only initializes a few
things, not really what you'd call a frontend enviroment
        require_once(PATH_tslib.'class.tslib_fe.php');
        require_once(PATH_t3lib.'class.t3lib_page.php');
        require_once(PATH_t3lib.'class.t3lib_userauth.php');
        require_once(PATH_tslib.'class.tslib_feuserauth.php');
        require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
        require_once(PATH_t3lib.'class.t3lib_cs.php');
        $temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
        $TSFE = new $temp_TSFEclassName(
                $TYPO3_CONF_VARS,
                t3lib_div::_GP('id'),
                t3lib_div::_GP('type'),
                t3lib_div::_GP('no_cache'),
                t3lib_div::_GP('cHash'),
                t3lib_div::_GP('jumpurl'),
                t3lib_div::_GP('MP'),
                t3lib_div::_GP('RDCT')
            );
        $TSFE->connectToDB();
        $TSFE->config = array();        // Must be filled with actual
config!
    }
    
    
More information about the TYPO3-dev
mailing list