Changeset 1075

Show
Ignore:
Timestamp:
09/06/08 01:14:49 (4 months ago)
Author:
laurentj
Message:

made performance improvements in jRequest
removed also deprecated members of jRequest: allowedResponses, , , .

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/buildjelix.php

    r1027 r1075  
    4141    ), 
    4242'WITH_BYTECODE_CACHE'=> array( 
    43     "says which bytecode cache engine will be recognized by jelix. Possible values :  'auto' (automatic detection), 'apc', 'eaccelerator' or '' for  none", 
     43    "says which bytecode cache engine will be recognized by jelix. Possible values :  'auto' (automatic detection), 'apc', 'eaccelerator', 'xcache' or '' for  none", 
    4444    'auto', 
    45     '/^(auto|apc|eaccelerator)?$/', 
     45    '/^(auto|apc|eaccelerator|xcache)?$/', 
    4646    ), 
    4747'ENABLE_DEVELOPER'=>array( 
     
    167167if($ENABLE_PHP_FILTER)  $BUILD_FLAGS |=8; 
    168168switch($WITH_BYTECODE_CACHE){ 
    169     case 'auto': $BUILD_FLAGS |=48; break; 
     169    case 'auto': $BUILD_FLAGS |=112; break; 
    170170    case 'apc': $BUILD_FLAGS |=16; break; 
    171171    case 'eaccelerator': $BUILD_FLAGS |=32; break; 
     172    case 'xcache': $BUILD_FLAGS |=64; break; 
    172173} 
    173174if($ENABLE_OLD_CLASS_NAMING)  $BUILD_FLAGS |=256; 
  • trunk/lib/jelix/core/defaultconfig.ini.php

    r1064 r1075  
    2525 
    2626enableOldActionSelector = 
     27 
     28; reserved variable 
     29requestScript= 
    2730 
    2831[coordplugins] 
     
    160163significantFile = "urls.xml" 
    161164 
     165; filled automatically by jelix 
     166urlScript= 
     167urlScriptPath= 
     168urlScriptName= 
     169 
    162170[simple_urlengine_entrypoints] 
    163171; parameters for the simple url engine. This is the list of entry points 
  • trunk/lib/jelix/core/jConfigCompiler.class.php

    r1062 r1075  
    4545        @jelix_read_ini(JELIX_APP_CONFIG_PATH.'defaultconfig.ini.php', $config); 
    4646 
    47         if($configFile !='defaultconfig.ini.php'){ 
     47        if($configFile != 'defaultconfig.ini.php'){ 
    4848            if(!file_exists(JELIX_APP_CONFIG_PATH.$configFile)) 
    4949                die("Jelix config file $configFile is missing !"); 
     
    5151                die("Syntax error in the Jelix config file $configFile !"); 
    5252        } 
    53  
     53#else 
     54        $config = jIniFile::read(JELIX_LIB_CORE_PATH.'defaultconfig.ini.php'); 
     55 
     56        if( $commonConfig = parse_ini_file(JELIX_APP_CONFIG_PATH.'defaultconfig.ini.php',true)){ 
     57            self::_mergeConfig($config, $commonConfig); 
     58        } 
     59 
     60        if($configFile !='defaultconfig.ini.php'){ 
     61            if(!file_exists(JELIX_APP_CONFIG_PATH.$configFile)) 
     62                die("Jelix config file $configFile is missing !"); 
     63            if( false === ($userConfig = parse_ini_file(JELIX_APP_CONFIG_PATH.$configFile,true))) 
     64                die("Syntax error in the Jelix config file $configFile !"); 
     65            self::_mergeConfig($config, $userConfig); 
     66        } 
     67        $config = (object) $config; 
     68#endif 
     69 
     70        self::prepareConfig($config); 
     71 
     72#if WITH_BYTECODE_CACHE == 'auto' 
     73        if(BYTECODE_CACHE_EXISTS){ 
     74            $filename=JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
     75            if ($f = @fopen($filename, 'wb')) { 
     76                fwrite($f, '<?php $config = '.var_export(get_object_vars($config),true).";\n?>"); 
     77                fclose($f); 
     78            } else { 
     79                throw new Exception('(24)Error while writing config cache file '.$filename); 
     80            } 
     81        }else{ 
     82            jIniFile::write(get_object_vars($config), JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php', ";<?php die('');?>\n"); 
     83        } 
     84#elseif WITH_BYTECODE_CACHE  
     85        $filename=JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
     86        if ($f = @fopen($filename, 'wb')) { 
     87            fwrite($f, '<?php $config = '.var_export(get_object_vars($config),true).";\n?>"); 
     88            fclose($f); 
     89        } else { 
     90            throw new Exception('(24)Error while writing config cache file '.$filename); 
     91        } 
     92#else 
     93        jIniFile::write(get_object_vars($config), JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php', ";<?php die('');?>\n"); 
     94#endif 
     95        return $config; 
     96    } 
     97 
     98    /** 
     99     * fill some config properties with calculated values 
     100     */ 
     101    static protected function prepareConfig($config){ 
     102         
    54103        $config->isWindows = (DIRECTORY_SEPARATOR === '\\'); 
    55104        if(trim( $config->startAction) == '') { 
     
    74123            $config->urlengine['scriptNameServerVariable'] = self::_findServerName($config->urlengine['entrypointExtension']); 
    75124        } 
    76  
    77         $path=$config->urlengine['basePath']; 
    78         if($path!='/' && $path!=''){ 
     125        $config->urlengine['urlScript'] = $_SERVER[$config->urlengine['scriptNameServerVariable']]; 
     126        $lastslash = strrpos ($config->urlengine['urlScript'], '/'); 
     127        $config->urlengine['urlScriptPath'] = substr ($config->urlengine['urlScript'], 0, $lastslash ).'/'; 
     128        $config->urlengine['urlScriptName'] = substr ($config->urlengine['urlScript'], $lastslash+1); 
     129 
     130        $path = $config->urlengine['basePath']; 
     131        if ($path != '/' && $path != '') { 
    79132            if($path{0} != '/') $path='/'.$path; 
    80133            if(substr($path,-1) != '/') $path.='/'; 
    81             $config->urlengine['basePath'] = $path; 
    82         } 
    83  
    84         if($path!='' && $config->urlengine['jelixWWWPath']{0} != '/') 
     134 
     135            if(strpos($config->urlengine['urlScriptPath'], $path) !== 0){ 
     136                throw new Exception('Jelix Error: basePath ('.$path.') in config file doesn\'t correspond to current base path. You should setup it to '.$config->urlengine['urlScriptPath']); 
     137            } 
     138 
     139        } else if ($path == '') { 
     140            // for beginners or simple site, we "guess" the base path 
     141            $path = $config->urlengine['urlScriptPath']; 
     142        } 
     143        $config->urlengine['basePath'] = $path; 
     144 
     145        if($config->urlengine['jelixWWWPath']{0} != '/') 
    85146            $config->urlengine['jelixWWWPath'] = $path.$config->urlengine['jelixWWWPath']; 
    86147 
     
    110171            die("Syntax error in the locale parameter in Jelix config file $configFile !"); 
    111172        }*/ 
    112 #else 
    113         $config = jIniFile::read(JELIX_LIB_CORE_PATH.'defaultconfig.ini.php'); 
    114  
    115         if( $commonConfig = parse_ini_file(JELIX_APP_CONFIG_PATH.'defaultconfig.ini.php',true)){ 
    116             self::_mergeConfig($config, $commonConfig); 
    117         } 
    118  
    119         if($configFile !='defaultconfig.ini.php'){ 
    120             if(!file_exists(JELIX_APP_CONFIG_PATH.$configFile)) 
    121                 die("Jelix config file $configFile is missing !"); 
    122             if( false === ($userConfig = parse_ini_file(JELIX_APP_CONFIG_PATH.$configFile,true))) 
    123                 die("Syntax error in the Jelix config file $configFile !"); 
    124             self::_mergeConfig($config, $userConfig); 
    125         } 
    126         $config['isWindows'] =  (DIRECTORY_SEPARATOR == '\\'); 
    127         if(trim( $config['startAction']) == '') { 
    128             $config['startAction'] = ':'; 
    129         } 
    130  
    131         $config['_allBasePath'] = array(); 
    132         $config['_modulesPathList'] = self::_loadPathList($config['modulesPath'], $config['_allBasePath']); 
    133  
    134         self::_loadPluginsPathList($config); 
    135  
    136         if($config['checkTrustedModules']){ 
    137             $config['_trustedModules'] = explode(',',$config['trustedModules']); 
    138             if(!in_array('jelix',$config['_trustedModules'])) 
    139                 $config['_trustedModules'][]='jelix'; 
    140         }else{ 
    141             $config['_trustedModules'] = array_keys($config['_modulesPathList']); 
    142         } 
    143  
    144         if($config['urlengine']['scriptNameServerVariable'] == '') { 
    145             $config['urlengine']['scriptNameServerVariable'] = self::_findServerName($config['urlengine']['entrypointExtension']); 
    146         } 
    147  
    148         $path=$config['urlengine']['basePath']; 
    149         if($path!='/' && $path!=''){ 
    150             if($path{0} != '/') $path='/'.$path; 
    151             if(substr($path,-1) != '/') $path.='/'; 
    152             $config['urlengine']['basePath'] = $path; 
    153         } 
    154  
    155         if($path!='' && $config['urlengine']['jelixWWWPath']{0} != '/') 
    156             $config['urlengine']['jelixWWWPath'] = $path.$config['urlengine']['jelixWWWPath']; 
    157  
    158         self::_initResponsesPath($config['responses']); 
    159         self::_initResponsesPath($config['_coreResponses']); 
    160         if (trim($config['timeZone']) === '') { 
    161 #if PHP50 
    162             $config['timeZone'] = "Europe/Paris"; 
    163 #else 
    164             $tz = ini_get('date.timezone'); 
    165             if ($tz != '') 
    166                 $config['timeZone'] = $tz; 
    167             else 
    168                 $config['timeZone'] = "Europe/Paris"; 
    169 #endif 
    170         } 
    171  
    172         /*if(preg_match("/^([a-zA-Z]{2})(?:_([a-zA-Z]{2}))?$/",$config['locale'],$m)){ 
    173             if(!isset($m[2])){ 
    174                 $m[2] = $m[1]; 
    175             } 
    176             $config['defaultLang'] = strtolower($m[1]); 
    177             $config['defaultCountry'] = strtoupper($m[2]); 
    178             $config['locale'] = $config['defaultLang'].'_'.$config['defaultCountry']; 
    179         }else{ 
    180             die("Syntax error in the locale parameter in Jelix config file $configFile !"); 
    181         }*/ 
    182 #endif 
    183  
    184 #if WITH_BYTECODE_CACHE == 'auto' 
    185         if(BYTECODE_CACHE_EXISTS){ 
    186             $filename=JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
    187             if ($f = @fopen($filename, 'wb')) { 
    188 #if ENABLE_PHP_JELIX 
    189                 fwrite($f, '<?php $config = '.var_export(get_object_vars($config),true).";\n?>"); 
    190 #else 
    191                 fwrite($f, '<?php $config = '.var_export($config,true).";\n?>"); 
    192 #endif 
    193                 fclose($f); 
    194             } else { 
    195                 throw new Exception('(24)Error while writing config cache file '.$filename); 
    196             } 
    197         }else{ 
    198 #if ENABLE_PHP_JELIX 
    199             jIniFile::write(get_object_vars($config), JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php', ";<?php die('');?>\n"); 
    200 #else 
    201             jIniFile::write($config, JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php', ";<?php die('');?>\n"); 
    202 #endif 
    203         } 
    204 #elseif WITH_BYTECODE_CACHE  
    205         $filename=JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.conf.php'; 
    206         if ($f = @fopen($filename, 'wb')) { 
    207 #if ENABLE_PHP_JELIX 
    208             fwrite($f, '<?php $config = '.var_export(get_object_vars($config),true).";\n?>"); 
    209 #else 
    210             fwrite($f, '<?php $config = '.var_export($config,true).";\n?>"); 
    211 #endif 
    212             fclose($f); 
    213         } else { 
    214             throw new Exception('(24)Error while writing config cache file '.$filename); 
    215         } 
    216 #else 
    217 #if ENABLE_PHP_JELIX 
    218         jIniFile::write(get_object_vars($config), JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php', ";<?php die('');?>\n"); 
    219 #else 
    220         jIniFile::write($config, JELIX_APP_TEMP_PATH.str_replace('/','~',$configFile).'.resultini.php', ";<?php die('');?>\n"); 
    221 #endif 
    222 #endif 
    223 #ifnot ENABLE_PHP_JELIX 
    224         $config = (object) $config; 
    225 #endif 
    226         return $config; 
    227173    } 
    228174 
     
    232178     * @return array list of full path 
    233179     */ 
    234     static private function _loadPathList($list, &$allBasePath){ 
     180    static protected function _loadPathList($list, &$allBasePath){ 
    235181        $list = split(' *, *',$list); 
    236182        array_unshift($list, JELIX_LIB_PATH.'core-modules/'); 
     
    259205    } 
    260206 
    261  
    262207    /** 
    263208     * Analyse plugin paths 
    264209     * @param array|object $config the config container 
    265210     */ 
    266     static private function _loadPluginsPathList(&$config){ 
    267 #if ENABLE_PHP_JELIX 
     211    static protected function _loadPluginsPathList(&$config){ 
    268212        $list = split(' *, *',$config->pluginsPath); 
    269 #else 
    270         $list = split(' *, *',$config['pluginsPath']); 
    271 #endif 
    272213        array_unshift($list, JELIX_LIB_PATH.'plugins/');  
    273214        foreach($list as $k=>$path){ 
     
    286227                        if($subdir = opendir($p.$f)){ 
    287228                            if($k!=0)  
    288 #if ENABLE_PHP_JELIX 
    289229                               $config->_allBasePath[]=$p.$f.'/'; 
    290 #else 
    291                                $config['_allBasePath'][]=$p.$f.'/'; 
    292 #endif 
    293230                            while (false !== ($subf = readdir($subdir))) { 
    294231                                if ($subf{0} != '.' && is_dir($p.$f.'/'.$subf)) { 
    295232                                    if($f == 'tpl'){ 
    296 #if ENABLE_PHP_JELIX 
    297233                                        $prop = '_tplpluginsPathList_'.$subf; 
    298234                                        $config->{$prop}[] = $p.$f.'/'.$subf.'/'; 
     
    300236                                        $prop = '_pluginsPathList_'.$f; 
    301237                                        $config->{$prop}[$subf] = $p.$f.'/'.$subf.'/'; 
    302 #else 
    303                                         $config['_tplpluginsPathList_'.$subf][] = $p.$f.'/'.$subf.'/'; 
    304                                     }else{ 
    305                                         $config['_pluginsPathList_'.$f][$subf] =$p.$f.'/'.$subf.'/'; 
    306 #endif 
    307238                                    } 
    308239                                } 
  • trunk/lib/jelix/core/jInstallChecker.class.php

    r1001 r1075  
    6767            'extension.xmlrpc'=>'Cette édition de Jelix a besoin de l\'extension xmlrpc', 
    6868            'extension.jelix'=>'Cette édition de Jelix a besoin de l\'extension jelix', 
    69             'extension.apc'=>'Cette édition de Jelix a besoin de l\'extension apc', 
    70             'extension.eaccelerator'=>'Cette édition de Jelix a besoin de l\'extension eaccelerator', 
     69            'extension.opcode.cache'=>'Cette édition de Jelix a besoin d\'une extension de cache d\'opcode (apc, eaccelerator...)', 
    7170            'path.core'=>'Le fichier init.php  de jelix ou le fichier application.ini.php de votre application n\'est pas chargé', 
    7271            'path.temp'=>'Le repertoire temporaire n\'est pas accessible en écriture ou alors JELIX_APP_TEMP_PATH n\'est pas configurée comme il faut', 
     
    122121            'extension.xmlrpc'=>'This Jelix edition require the xmlrpc extension', 
    123122            'extension.jelix'=>'This Jelix edition require the jelix extension', 
    124             'extension.apc'=>'This Jelix edition require the apc extension', 
    125             'extension.eaccelerator'=>'This Jelix edition require the eaccelerator extension', 
     123            'extension.opcode.cache'=>'This Jelix edition require an extension for opcode cache (apc, eaccelerator...)', 
    126124            'path.core'=>'jelix init.php file or application.ini.php file is not loaded', 
    127125            'path.temp'=>'temp/yourApp directory is not writable or JELIX_APP_TEMP_PATH is not correctly set !', 
     
    306304            $ok=false; 
    307305        } 
    308         if($this->buildProperties['WITH_BYTECODE_CACHE'] == 'apc' && !extension_loaded ('apc')) { 
    309             $this->error('extension.apc'); 
    310             $ok=false; 
    311         } 
    312         if($this->buildProperties['WITH_BYTECODE_CACHE'] == 'eaccelerator' && !extension_loaded ('eaccelerator')) { 
    313             $this->error('extension.eaccelerator'); 
    314             $ok=false; 
    315         } 
    316  
     306        if($this->buildProperties['WITH_BYTECODE_CACHE'] != 'auto' && $this->buildProperties['WITH_BYTECODE_CACHE'] != '') { 
     307            if(!extension_loaded ('apc') && !extension_loaded ('eaccelerator') && !extension_loaded ('xcache')) { 
     308                $this->error('extension.opcode.cache'); 
     309                $ok=false; 
     310            } 
     311        } 
    317312        if($ok) 
    318313            $this->ok('extensions.required.ok'); 
  • trunk/lib/jelix/core/jRequest.class.php

    r933 r1075  
    6767    public $urlPathInfo; 
    6868 
    69  
    70     /** 
    71      * @var string 
    72      * @deprecated see $urlScriptPath 
    73      */ 
    74     public $url_script_path; 
    75  
    76     /** 
    77      * @var string 
    78      * @deprecated see $urlScriptName 
    79      */ 
    80     public $url_script_name; 
    81  
    82     /** 
    83      * @var string 
    84      * @deprecated see $urlPathInfo 
    85      */ 
    86     public $url_path_info; 
    87  
    88  
    89  
    9069    function __construct(){  } 
    9170 
     
    10988        global $gJConfig; 
    11089 
    111         if (isset($_SERVER[$gJConfig->urlengine['scriptNameServerVariable']])) 
    112             $this->urlScript = $_SERVER[$gJConfig->urlengine['scriptNameServerVariable']]; 
    113         else 
    114             $this->urlScript = $_SERVER['SCRIPT_NAME']; 
    115  
    116         $lastslash = strrpos ($this->urlScript, '/'); 
    117         $this->url_script_path = $this->urlScriptPath = substr ($this->urlScript, 0, $lastslash ).'/'; 
    118  
    119         if($gJConfig->urlengine['basePath'] == ''){ // for beginners or simple site, we "guess" the base path 
    120             $gJConfig->urlengine['basePath'] = $this->urlScriptPath; 
    121             if($gJConfig->urlengine['jelixWWWPath']{0} != '/') 
    122                 $gJConfig->urlengine['jelixWWWPath'] = $this->urlScriptPath.$gJConfig->urlengine['jelixWWWPath']; 
    123         }else if(strpos($this->urlScriptPath,$gJConfig->urlengine['basePath']) !== 0){ 
    124             throw new Exception('Jelix Error: basePath ('.$gJConfig->urlengine['basePath'].') in config file doesn\'t correspond to current base path. You should setup it to '.$this->urlScriptPath); 
    125         } 
    126  
    127         $this->url_script_name = $this->urlScriptName = substr ($this->urlScript, $lastslash+1); 
     90        $this->urlScript = $gJConfig->urlengine['urlScript']; 
     91        $this->urlScriptPath = $gJConfig->urlengine['urlScriptPath']; 
     92        $this->urlScriptName = $gJConfig->urlengine['urlScriptName']; 
    12893 
    12994        $piiqp = $gJConfig->urlengine['pathInfoInQueryParameter']; 
     
    151116        } 
    152117 
    153         $this->url_path_info = $this->urlPathInfo = $pathinfo; 
     118        $this->urlPathInfo = $pathinfo; 
    154119    } 
    155120 
     
    175140 
    176141    /** 
    177      * return a list of class name of allowed response corresponding to the request 
    178      * @return array the list, or false which means everything 
    179      * @see jRequest::getResponse() 
    180      */ 
    181     public function allowedResponses(){ return false;} 
    182  
    183     /** 
    184142     * @param string $respclass the name of a response class 
    185143     */ 
    186144    public function isAllowedResponse($respclass){ 
    187         if($ar=$this->allowedResponses()){ 
    188             return in_array($respclass, $ar); 
    189         }else 
    190             return true; 
     145        return true; 
    191146    } 
    192147 
  • trunk/lib/jelix/core/request/jCmdLineRequest.class.php

    r1001 r1075  
    2525    public $defaultResponseType = 'cmdline'; 
    2626 
    27     public function allowedResponses(){ 
    28         return array('jResponseCmdline'); 
     27    public function isAllowedResponse($respclass){ 
     28        return ('jResponseCmdline' == $respclass); 
    2929    } 
    3030 
    3131    protected function _initUrlData(){  
    3232        global $gJConfig;  
    33         $this->url_script_path = $this->urlScriptPath = '/';  
    34         $this->url_script_name = $this->urlScriptName = $this->urlScript = $_SERVER['SCRIPT_NAME'];  
    35         $this->url_path_info = $this->urlPathInfo = '';  
     33        $this->urlScriptPath = '/';  
     34        $this->urlScriptName = $this->urlScript = $_SERVER['SCRIPT_NAME'];  
     35        $this->urlPathInfo = '';  
    3636    } 
    3737 
  • trunk/lib/jelix/core/request/jCssRequest.class.php

    r1001 r1075  
    2727    } 
    2828 
    29     public function allowedResponses(){ return array('jResponseCss');} 
     29    public function isAllowedResponse($respclass){ 
     30        return ('jResponseCss' == $respclass); 
     31    } 
    3032} 
  • trunk/lib/jelix/core/request/jJsonRpcRequest.class.php

    r1026 r1075  
    6161    } 
    6262 
    63     public function allowedResponses(){ return array('jResponseJsonrpc');} 
     63    public function isAllowedResponse($respclass){ 
     64        return ('jResponseJsonrpc' == $respclass); 
     65    } 
    6466 
    6567} 
  • trunk/lib/jelix/core/request/jRdfRequest.class.php

    r1001 r1075  
    2626        $this->params = array_merge($url->params, $_POST); 
    2727    } 
    28     public function allowedResponses(){ return array('jResponseRdf');} 
    2928 
     29    public function isAllowedResponse($respclass){ 
     30        return ('jResponseRdf' == $respclass); 
     31    } 
    3032} 
    3133 
  • trunk/lib/jelix/core/request/jSoapRequest.class.php

    r879 r1075  
    5858    protected function _initParams(){} 
    5959 
    60     public function allowedResponses(){  
    61         return array('jResponseSoap'); 
     60    public function isAllowedResponse($respclass){ 
     61        return ('jResponseSoap' == $respclass); 
    6262    } 
    6363 
  • trunk/lib/jelix/core/request/jXmlRpcRequest.class.php

    r1001 r1075  
    5757    } 
    5858 
    59     public function allowedResponses(){ return array('jResponseXmlrpc');} 
     59    public function isAllowedResponse($respclass){ 
     60        return ('jResponseXmlrpc' == $respclass); 
     61    } 
    6062 
    6163} 
  • trunk/lib/jelix/init.php

    r1074 r1075  
    5353 
    5454#if WITH_BYTECODE_CACHE == 'auto' 
    55 define ('BYTECODE_CACHE_EXISTS', function_exists('apc_cache_info')|| function_exists('eaccelerator_info')); 
     55define ('BYTECODE_CACHE_EXISTS', function_exists('apc_cache_info') || function_exists('eaccelerator_info') || function_exists('xcache_info')); 
     56#elseif WITH_BYTECODE_CACHE 
     57define ('BYTECODE_CACHE_EXISTS', true); 
     58#else 
     59define ('BYTECODE_CACHE_EXISTS', false); 
    5660#endif 
    5761 
  • trunk/testapp/modules/jelix_tests/tests/core.jrequest.html_cli.php

    r722 r1075  
    1010*/ 
    1111 
    12  
     12require_once(JELIX_LIB_CORE_PATH.'jConfigCompiler.class.php'); 
     13 
     14 
     15class configCompileTest extends jConfigCompiler { 
     16     
     17    static public function prepareConfig2($config){ 
     18        self::prepareConfig($config); 
     19    } 
     20
    1321 
    1422class requestTest extends jRequest { 
     
    2129class UTjrequest extends jUnitTestCase { 
    2230    protected $currentServer; 
    23     protected $currentBasePath; 
    24     protected $currentConfigScriptName; 
    25  
     31    protected $currentConfig; 
     32     
    2633    function setUp() { 
    2734        $this->currentServer = $_SERVER; 
    28         $this->currentConfigScriptName = $GLOBALS['gJConfig']->urlengine['scriptNameServerVariable']; 
    29         $this->currentBasePath = $GLOBALS['gJConfig']->urlengine['basePath']; 
     35        $this->currentConfig = clone $GLOBALS['gJConfig']; 
    3036        $GLOBALS['gJConfig']->urlengine['basePath'] = '/'; 
     37        $GLOBALS['gJConfig']->responses=array(); 
     38        $GLOBALS['gJConfig']->_coreResponses=array(); 
    3139    } 
    3240 
    3341    function tearDown() { 
    3442        $_SERVER = $this->currentServer; 
    35         $GLOBALS['gJConfig']->urlengine['scriptNameServerVariable'] = $this->currentConfigScriptName; 
    36         $GLOBALS['gJConfig']->urlengine['basePath'] = $this->currentBasePath; 
     43        $GLOBALS['gJConfig'] = clone $this->currentConfig; 
    3744    } 
    3845 
     
    5360        ); 
    5461        $req = new requestTest(); 
     62        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    5563        $req->init(); 
    5664 
     
    7886        ); 
    7987        $req = new requestTest(); 
     88        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    8089        $req->init(); 
    8190 
     
    99108        ); 
    100109        $req = new requestTest(); 
     110        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    101111        $req->init(); 
    102112 
     
    121131        ); 
    122132        $req = new requestTest(); 
     133        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    123134        $req->init(); 
    124135 
     
    141152        ); 
    142153        $req = new requestTest(); 
     154        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    143155        $req->init(); 
    144156 
     
    168180        ); 
    169181        $req = new requestTest(); 
     182        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    170183        $req->init(); 
    171184        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    189202        ); 
    190203        $req = new requestTest(); 
     204        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    191205        $req->init(); 
    192206        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    210224        ); 
    211225        $req = new requestTest(); 
     226        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    212227        $req->init(); 
    213228        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    230245        ); 
    231246        $req = new requestTest(); 
     247        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    232248        $req->init(); 
    233249        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    256272        ); 
    257273        $req = new requestTest(); 
     274        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    258275        $req->init(); 
    259276        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    279296       ); 
    280297        $req = new requestTest(); 
     298        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    281299        $req->init(); 
    282300        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    304322       ); 
    305323        $req = new requestTest(); 
     324        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    306325        $req->init(); 
    307326        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    326345        ); 
    327346        $req = new requestTest(); 
     347        configCompileTest::prepareConfig2($GLOBALS['gJConfig']); 
    328348        $req->init(); 
    329349        $this->assertEqual('/foo/', $req->urlScriptPath); 
     
    334354} 
    335355 
    336 ?> 
Download in other formats: Unified Diff Zip Archive