Changeset 948

Show
Ignore:
Timestamp:
07/24/08 06:40:11 (3 months ago)
Author:
arnoschn
Message:

adding interactive setup in phing script which creates the config files for the CI tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/arnoschn/cache

    • Property svn:ignore deleted
  • branches/arnoschn/cache/CiTestsTask.php

    r929 r948  
    77    var $_apacheUser = 'www-data'; 
    88    var $_apacheGroup = 'www-data'; 
     9    var $_testDir; 
     10    var $_args; 
    911    public function setAkelosPath($path) 
    1012    { 
    1113        $this->_akelosPath = $path; 
    1214    } 
     15    public function setArgs($args) 
     16    { 
     17        $this->_args = $args; 
     18    } 
    1319     
     20    public function setTestDir($dir) 
     21    { 
     22        $this->_testDir = $dir; 
     23    } 
    1424    public function setApacheGroup($group) 
    1525    { 
     
    2232    public function main() 
    2333    { 
     34         
    2435        $this->_installTestApp(); 
    2536        $this->_copyFiles(); 
     
    2940    private function _runTests() 
    3041    { 
    31         chdir($this->_akelosPath.DS.$this->_testPath); 
    32         $this->_execute('chgrp -R ' .$this->_apacheGroup.' ' .$this->_akelosPath.DS.$this->_testPath); 
    33         $this->_execute('chown -R ' .$this->_apacheUser.' ' .$this->_akelosPath.DS.$this->_testPath); 
    34         $this->_execute('export AK_FRAMEWORK_DIR="'.$this->_akelosPath.'";/usr/bin/env php  '.$this->_akelosPath.DS.$this->_testPath.'/script/extras/xinc-ci_tests.php',true); 
     42        chdir($this->_testDir); 
     43        $this->_execute('rm -Rf ' .$this->_testDir.'/test-results*.xml'); 
     44        //$this->_execute('chown -R ' .$this->_apacheUser.' ' .$this->_akelosPath.DS.$this->_testPath); 
     45        $this->_execute('/usr/bin/env php  '.$this->_testDir.'/script/extras/xinc-ci_tests.php '.$this->_args,true); 
    3546    } 
    3647     
     
    3849    { 
    3950        !defined('DS')?define('DS',DIRECTORY_SEPARATOR):null; 
    40         //passthru('rm -Rf '.$this->_testPath); 
    41         $excludeTestPath = basename($this->_testPath).' nanoweb'; 
    42         //mkdir($this->_testPath,0777,true); 
    43         $this->_execute($this->_akelosPath.'/akelos -d '.$this->_testPath.' --force -e '.$excludeTestPath,true); 
    44         //$this->_execute('rm -Rf '.$this->_testPath.DS.'app'.DS.'* ',true); 
    45         //$this->_execute('rm -Rf '.$this->_testPath.DS.'public'.DS.'* ',true); 
    46         //$this->_execute("cp -Rf ".$this->_akelosPath.DS.'test'.DS.'fixtures'.DS.'app'."   ".$this->_testPath.DS, true); 
    47         //$this->_execute("cp -Rf ".$this->_akelosPath.DS.'test'.DS.'fixtures'.DS.'public'."   ".$this->_testPath.DS, true); 
    48         $this->_execute("touch ".$this->_testPath.DS.'log'.DS."testing.log", true); 
    49         $this->_execute("chmod 777 ".$this->_testPath.DS.'log'.DS."testing.log", true); 
    50         $this->_execute("cp -Rf ".$this->_akelosPath.DS.'test'."   ".$this->_testPath.DS, true); 
    51         $this->_execute("cp  ".$this->_akelosPath.DS.'test'.DS.'.nwaccess'."   ".$this->_testPath.DS, true); 
    52         $this->_execute("find ".$this->_testPath.DS."/ -type d  -name '.svn' -exec sh -c 'exec rm -Rf \"$@\"' find-copy {} +",true); 
    53         //$this->_execute("cp -Rf ".$this->_akelosPath.DS.'tmp'.DS.'installer_versions'."   ".$this->_testPath.DS.'test'.DS.'tmp', true); 
    54         //$this->_execute("cp -Rf ".$this->_akelosPath.DS.'tmp'.DS.'installer_versions'."   ".$this->_testPath.DS.'tmp', true); 
    55         //$this->_execute("cp -Rf ".$this->_akelosPath.DS.'test'.DS.'suites'."   ".$this->_testPath.DS.'test'.DS, true); 
     51        $this->_execute($this->_akelosPath.'/akelos -d '.$this->_testDir.' -deps --force',true); 
     52        $this->_execute("touch ".$this->_testDir.DS.'log'.DS."testing.log", true); 
     53        $this->_execute("chmod 777 ".$this->_testDir.DS.'log'.DS."testing.log", true); 
     54        $this->_execute("cp -Rf ".$this->_akelosPath.DS.'test'."   ".$this->_testDir.DS, true); 
     55        $this->_execute("cp  ".$this->_akelosPath.DS.'test'.DS.'.nwaccess'."   ".$this->_testDir.DS, true); 
     56        //$this->_execute("find ".$this->_testDir.DS."/ -type d  -name '.svn' -exec sh -c 'exec rm -Rf \"$@\"' find-copy {} +",true); 
    5657    } 
    5758    private function _execute($cmd,$execute=true) 
     
    7879         
    7980        foreach ($files as $file=>$dest) { 
    80             $this->_execute('cp '.(isset($dest[1])?$dest[1]:'').' '.$this->_akelosPath.DIRECTORY_SEPARATOR.$file.' '.$this->_testPath.DIRECTORY_SEPARATOR.$dest[0].DIRECTORY_SEPARATOR.basename($file)); 
     81            $this->_execute('cp '.(isset($dest[1])?$dest[1]:'').' '.$this->_akelosPath.DIRECTORY_SEPARATOR.$file.' '.$this->_testDir.DIRECTORY_SEPARATOR.$dest[0].DIRECTORY_SEPARATOR.basename($file)); 
    8182        } 
    8283 
  • branches/arnoschn/cache/build-test.xml

    r931 r948  
    22<project name="LP2 Build File For Unit Tests" basedir="." default="build"> 
    33 
    4         <property name="report.dir" value="report" /> 
    5         <property name="codecoverage" value="false" override="true" /> 
    6         <property name="coverage.dir" value="report/coverage" /> 
    7         <property name="coverage.subdir" value="coverage" /> 
    8  
    9         <property name="coverage.database" value="./report/coverage/database" /> 
     4        <property file="build.properties"/> 
     5        <property name="report.dir" value="${project.basedir}/test/report" /> 
     6        <property name="test.dir" value="${project.basedir}/ci-tests" /> 
     7        <property name="config.dir" value="${project.basedir}/script/extras" /> 
     8        <property name="config.file" value="${config.dir}/ci-config.yaml" /> 
    109        <fileset dir="lib" id="akelos-classes"> 
    1110                <include name="*/**/*.php" /> 
    1211        </fileset> 
     12 
     13        <target name="taskdef"> 
     14                <taskdef name="ci-tests" classname="CiTestsTask" classpath="${project.basedir}" /> 
     15                <taskdef name="ci-reports" classname="CiReportTask" classpath="${project.basedir}" /> 
     16                <taskdef name="ci-rewrite-url" classname="CiRewriteUrlTask" classpath="${project.basedir}" /> 
     17        </target> 
     18 
     19        <target name="interactive" depends="taskdef,check-config"> 
     20                <if> 
     21                        <equals arg1="${akelos_path}" arg2="" /> 
     22                        <then> 
     23                                <property name="akelos_path" value="${project.basedir}" override="true" /> 
     24                        </then> 
     25                </if> 
     26                <if> 
     27                        <equals arg1="${test_dir}" arg2="" /> 
     28                        <then> 
     29                                <property name="test_dir" value="${test.dir}" override="true" /> 
     30                        </then> 
     31                </if> 
     32                <echo> 
     33            params: 
     34                        all 
     35                         
     36            run all unit tests in any combination. 
     37             
     38            params: 
     39            php5 postgres mysql AkHasMany AkBelongsTo 
     40             
     41            run AkHasMany and AkBelongsTo on PHP5 using the postgres and mysql-db. 
     42                </echo> 
     43                <input propertyname="akelos_path" message="Please provide the akelos path containing the version you want to test" promptChar=":" defaultValue="${akelos_path}" /> 
     44                <input propertyname="test_dir" message="Please provide the directory the test app should be installed in" promptChar=":" defaultValue="${test_dir}" /> 
     45                <input propertyname="arguments" message="Please provide run arguments. No arguments will run all valid combinations" promptChar=":" defaultValue="${arguments}" /> 
     46                <phingCall target="run-tests"> 
     47                        <param name="akelos_path" value="${akelos_path}" /> 
     48                        <param name="test_dir" value="${test_dir}" /> 
     49                        <param name="arguments" value="${arguments}" /> 
     50                </phingCall> 
     51        </target> 
     52        <target name="validate-akelos"> 
     53                <available file="${akelos_path}/akelos" property="akelos_available" /> 
     54                <fail unless="akelos_available" message="akelos could not be found in ${akelos_path}" /> 
     55        </target> 
     56 
     57        <target name="run-tests"> 
     58                <copy file="TPL-build.properties" tofile="build.properties" overwrite="true"> 
     59                        <filterchain> 
     60                                <expandproperties /> 
     61                        </filterchain> 
     62                </copy> 
     63                <phingCall target="validate-akelos" /> 
     64                <ci-tests akelosPath="${akelos_path}" testDir="${test_dir}" args="${arguments}" /> 
     65                <phingCall target="generate-reports"> 
     66                        <param name="test.dir" value="${test_dir}" /> 
     67                </phingCall> 
     68        </target> 
     69        <target name="generate-reports"> 
     70                <ci-reports styledir="resources/xsl" reportdir="${report.dir}" format="noframes"> 
     71                        <fileset dir="${test.dir}"> 
     72                                <include name="test-results*.xml" /> 
     73                        </fileset> 
     74 
     75                </ci-reports> 
     76        </target> 
     77                 
     78        <target name="check-config"> 
     79                <echo>Checking configuration</echo> 
     80                <available file="${config.file}" property="config.exists" value="1" /> 
     81                <if> 
     82                        <equals arg1="${config.exists}" arg2="1" /> 
     83                        <then> 
     84                                <echo>${config.file} exists</echo> 
     85                        </then> 
     86                        <else> 
     87                                <echo>${config.file} does not exist</echo> 
     88                                <phingCall target="generate-config" /> 
     89 
     90                        </else> 
     91                </if> 
     92        </target> 
    1393         
     94        <target name="setup" depends="taskdef,generate-config"/> 
     95        <target name="generate-config"> 
     96                <echo>Generating config</echo> 
     97                <input propertyname="testing.url" message="[WebServer] Please provide the url under which the testing website can be found" promptChar=":" defaultValue="http://localhost/test/fixtures/public" /> 
     98                <phingCall target="generate-config-mysql"> 
     99                        <param name="testing.url" value="${testing.url}" /> 
     100                </phingCall> 
     101                <phingCall target="generate-config-postgres"> 
     102                        <param name="testing.url" value="${testing.url}" /> 
     103                </phingCall> 
     104                <phingCall target="generate-config-sqlite"> 
     105                        <param name="testing.url" value="${testing.url}" /> 
     106                </phingCall> 
     107                <phingCall target="generate-yaml-config-file" /> 
     108                <phingCall target="generate-fix-htaccess" /> 
     109        </target> 
     110        <target name="generate-config-mysql"> 
     111                <phingCall target="generate-config-file"> 
     112                        <param name="type" value="mysql" /> 
     113 
     114                        <param name="testing.url" value="${testing.url}" /> 
     115                </phingCall> 
     116        </target> 
     117        <target name="generate-config-postgres"> 
     118                <phingCall target="generate-config-file"> 
     119                        <param name="type" value="postgres" /> 
     120 
     121                        <param name="testing.url" value="${testing.url}" /> 
     122                </phingCall> 
     123        </target> 
     124        <target name="generate-config-sqlite"> 
     125                <phingCall target="generate-config-file"> 
     126                        <param name="type" value="sqlite" /> 
     127                        <param name="file.based" value="1" /> 
     128                        <param name="testing.url" value="${testing.url}" /> 
     129                </phingCall> 
     130        </target> 
     131        <target name="generate-config-file"> 
     132 
     133                <if> 
     134                        <equals arg1="${file.based}" arg2="1" /> 
     135                        <then> 
     136                                <input propertyname="file" message="[${type}] Please provide which database-file should be used" promptChar=":" defaultValue="" /> 
     137                                <property name="database" value="" /> 
     138                                <property name="host" value="" /> 
     139                                <property name="user" value="" /> 
     140                                <property name="password" value="" /> 
     141                        </then> 
     142 
     143                        <else> 
     144                                <input propertyname="host" message="[${type}] Please provide which host should be used" promptChar=":" defaultValue="localhost" /> 
     145                                <property name="file" value="" /> 
     146                                <input propertyname="database" message="[${type}] Please provide which database should be used" promptChar=":" defaultValue="framework_tests" /> 
     147                                <input propertyname="user" message="[${type}] Please provide which user should be used" promptChar=":" defaultValue="akelos" /> 
     148                                <input propertyname="password" message="[${type}] Please provide which password should be used" promptChar=":" /> 
     149                        </else> 
     150                </if> 
     151 
     152 
     153                <copy file="${config.dir}/TPL-config-testing.php" tofile="${config.dir}/${type}-testing.php" overwrite="true"> 
     154                        <filterchain> 
     155                                <expandproperties /> 
     156                        </filterchain> 
     157                </copy> 
     158        </target> 
     159        <target name="generate-fix-htaccess"> 
     160                <ci-rewrite-url url="${testing.url}" property="rewrite.url"/> 
     161                <copy file="${config.dir}/TPL-fix_htaccess.php" tofile="${config.dir}/fix_htaccess.php" overwrite="true"> 
     162                    <filterchain> 
     163                        <expandproperties /> 
     164                    </filterchain> 
     165                </copy> 
     166            </target> 
     167        <target name="generate-yaml-config-file"> 
     168 
     169                <input propertyname="php5" message="Please provide the path to the php5 executable" promptChar=":" defaultValue="/usr/bin/php5" /> 
     170                <input propertyname="php4" message="Please provide the path to the php4 executable" promptChar=":" defaultValue="/usr/bin/php4" /> 
     171 
     172 
     173                <copy file="${config.dir}/TPL-ci-config.yaml" tofile="${config.dir}/ci-config.yaml" overwrite="true"> 
     174                        <filterchain> 
     175                                <expandproperties /> 
     176                        </filterchain> 
     177                </copy> 
     178        </target> 
    14179        <target name="prepare"> 
    15180 
    16181                <mkdir dir="${report.dir}" /> 
    17                 <mkdir dir="${project.basedir}/ci-tests" /> 
     182                <mkdir dir="${test.dir}" /> 
    18183        </target> 
    19184 
    20         <target name="generate-report"> 
    21                 <mkdir dir="${report.dir}/${phpversion}" /> 
    22                 <mkdir dir="${report.dir}/${phpversion}/${environment}" /> 
    23                 <phpunit2report infile="${project.basedir}/ci-tests/test-results-${phpversion}-${environment}.xml" styledir="resources/xsl" todir="${report.dir}/${phpversion}/${environment}" format="noframes" /> 
    24  
    25         </target> 
    26         <target name="test"> 
    27                 <taskdef name="ci-tests" classname="CiTestsTask" classpath="${project.basedir}" /> 
    28                 <copy todir="${project.basedir}/tmp"> 
    29                             <filterchain> 
    30                                 <expandproperties /> 
    31                             </filterchain> 
    32                             <fileset dir="${project.basedir}/test/nanoweb/etc"> 
    33                                 <include name="nanoweb.conf" /> 
    34                                 <include name="modules.conf" /> 
    35                             </fileset> 
    36                         </copy> 
    37                 <exec command='${project.basedir}/test/nanoweb/bin/nanoweb.php --config=${project.basedir}/tmp/nanoweb.conf --set-option="PidFile=${project.basedir}/tmp/nanoweb.pid"' spawn="true" passthru="true"/> 
    38                 <ci-tests akelosPath="${project.basedir}" /> 
    39                 <exec command="kill `cat ${project.basedir}/tmp/nanoweb.pid` >/dev/null 2>/dev/null"/> 
    40                         <exec command="rm ${project.basedir}/tmp/nanoweb.pid"/> 
    41         </target> 
    42  
    43         <target name="report"> 
    44                 <phingCall target="generate-report"> 
    45                         <property name="phpversion" value="php5" /> 
    46                         <property name="environment" value="mysql" /> 
    47                 </phingCall> 
    48                 <phingCall target="generate-report"> 
    49                         <property name="phpversion" value="php4" /> 
    50                         <property name="environment" value="mysql" /> 
    51                 </phingCall> 
    52                 <phingCall target="generate-report"> 
    53                         <property name="phpversion" value="php5" /> 
    54                         <property name="environment" value="postgres" /> 
    55                 </phingCall> 
    56                 <phingCall target="generate-report"> 
    57                         <property name="phpversion" value="php4" /> 
    58                         <property name="environment" value="postgres" /> 
    59                 </phingCall> 
    60                 <phingCall target="generate-report"> 
    61                         <property name="phpversion" value="php5" /> 
    62                         <property name="environment" value="sqlite" /> 
    63                 </phingCall> 
    64         </target> 
    65  
    66         <target name="build" depends="prepare,test,report"> 
     185        <target name="build" depends="taskdef,check-config,run-tests"> 
    67186        </target> 
    68187 
  • branches/arnoschn/cache/lib/Ak.php

    r929 r948  
    358358            if(!$result = file_put_contents($options['base_path'].DS.$file_name, $content)){ 
    359359                if(!empty($content)){ 
    360                     Ak::trace("Please change file/dir permissions or enable FTP file handling by". 
     360                    Ak::trace("Could not write to file: \"".$options['base_path'].DS."$file_name\". Please change file/dir permissions or enable FTP file handling by". 
    361361                    " setting the following on your config/".AK_ENVIRONMENT.".php file \n<pre>define('AK_UPLOAD_FILES_USING_FTP', true);\n". 
    362362                    "define('AK_READ_FILES_USING_FTP', false);\n". 
  • branches/arnoschn/cache/script/extras/DEFAULT-mysql-testing.php

    r933 r948  
    66    'host' => 'localhost', 
    77    'database_name' => 'framework_tests', 
    8     'user' => '', 
    9     'password' => '', 
     8    'user' => 'arno', 
     9    'password' => 'arno', 
    1010    'options' => '' 
    1111)); 
    1212 
    1313$database_settings['development'] = $database_settings['production'] = $database_settings['testing']; 
    14 defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); 
     14 
    1515defined('AK_ENVIRONMENT') ? null : define('AK_ENVIRONMENT', 'testing'); 
    1616defined('AK_BASE_DIR') ? null : define('AK_BASE_DIR', str_replace(DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php','',__FILE__)); 
    17 defined('AK_FRAMEWORK_DIR') ? null : define('AK_FRAMEWORK_DIR', str_replace(DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php',DS.'..'.DS,__FILE__)); 
    18 defined('AK_TESTING_URL') ? null : define('AK_TESTING_URL', 'http://localhost:8181/test/fixtures/public'); 
     17defined('AK_TESTING_URL') ? null : define('AK_TESTING_URL', 'http://localhost:81/test/fixtures/public'); 
    1918define('AK_LOG_EVENTS', true); 
    20 defined('AK_TMP_DIR') ? null : define('AK_TMP_DIR', AK_BASE_DIR.DS.'test'.DS.'tmp'); 
     19 
    2120include('fix_htaccess.php'); 
    2221 
  • branches/arnoschn/cache/script/extras/xinc-ci_tests.php

    r929 r948  
    4040    function loadSettings($filename=AK_CI_CONFIG_FILE) 
    4141    { 
    42         require dirname(__FILE__).DS.'..'.DS.'..'.DS.'..'.DS.'vendor'.DS.'TextParsers'.DS.'spyc.php'; 
     42        require dirname(__FILE__).DS.'..'.DS.'..'.DS.'vendor'.DS.'TextParsers'.DS.'spyc.php'; 
    4343 
    4444        if (!is_file($filename)){ 
     
    5252    { 
    5353        array_shift($args); 
     54         
    5455        while (count($args) > 0){ 
    5556            $arg = array_shift($args); 
  • branches/arnoschn/cache/script/setup

    r929 r948  
    3131        'quiet' => false, 
    3232        'public_html' => false, 
    33         'exclude' => false, 
    3433        'dependencies' => false 
    3534        ); 
     
    5554            } 
    5655        } 
    57         if(!empty($this->options['exclude'])){ 
    58             $this->framework_dirs = array('lib', 'vendor', 'test'); 
    59             $excludes = !is_array($this->options['exclude'])?array($this->options['exclude']):$this->options['exclude']; 
    60             foreach ($excludes as $exclude_dir){ 
    61                 foreach ($this->source_tree as $k => $v){ 
    62                     if(isset($v[$exclude_dir])){ 
    63                         unset($this->source_tree[$k]) ; 
    64                     } 
    65                 } 
    66             } 
    67         } 
     56 
    6857        $this->destination_tree = Ak::dir($this->options['directory'],array('dirs'=>true,'recurse'=>true)); 
    6958    } 
     
    10392        $test_dir = $this->options['directory'].DS.'test'; 
    10493 
    105         $this->_makeDir($test_dir,true); 
     94        $this->_makeDir($test_dir); 
    10695        $this->_copyFile($source_test_dir.DS.'app.php'); 
    10796 
    108         $this->_makeDir($test_dir.DS.'fixtures',true); 
    109         $this->_makeDir($test_dir.DS.'fixtures'.DS.'app',true); 
     97        $this->_makeDir($test_dir.DS.'fixtures'); 
     98        $this->_makeDir($test_dir.DS.'fixtures'.DS.'app'); 
    11099 
    111100        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'app'.DS.'application_controller.php'); 
    112101        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'app'.DS.'shared_model.php'); 
    113102 
    114         $this->_makeDir($test_dir.DS.'fixtures'.DS.'config',true); 
     103        $this->_makeDir($test_dir.DS.'fixtures'.DS.'config'); 
    115104        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'config'.DS.'config.php'); 
    116105 
    117         $this->_makeDir($test_dir.DS.'fixtures'.DS.'data',true); 
    118         $this->_makeDir($test_dir.DS.'fixtures'.DS.'public',true); 
     106        $this->_makeDir($test_dir.DS.'fixtures'.DS.'data'); 
     107        $this->_makeDir($test_dir.DS.'fixtures'.DS.'public'); 
    119108        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'public'.DS.'.htaccess'); 
    120109        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'public'.DS.'index.php'); 
     
    200189    } 
    201190 
    202     function _makeDir($path, $takeAsIs=false) 
    203     { 
    204         if ($takeAsIs) { 
    205             $dir = $path; 
    206         } else { 
    207             $dir = $this->_getDestinationPath($path); 
    208         } 
    209          
     191    function _makeDir($path) 
     192    { 
     193        $dir = $this->_getDestinationPath($path); 
     194 
    210195        if($this->_canUsePath($dir)){ 
    211196            if(!is_dir($dir)){ 
     
    214199                return false; 
    215200            } 
     201        } 
     202        $source_file_mode =  fileperms($path); 
     203        $target_file_mode =  fileperms($dir); 
     204        if($source_file_mode != $target_file_mode){ 
     205            $this->yield("    Setting $dir permissions to: ".(sprintf("%o",$source_file_mode))); 
     206            chmod($dir,$source_file_mode); 
    216207        } 
    217208        return true; 
     
    456447'desc'    => 'Show this help message.'), 
    457448 
    458 'exclude' => array( 
    459 'short'   => 'e', 
    460 'max'     => -1, 
    461 'min'     => 0, 
    462 'desc'    => 'Exclude directories when creating the application'), 
    463449 
    464450); 
  • branches/arnoschn/cache/test

    • Property svn:ignore set to
      report
  • branches/arnoschn/cache/test/unit/lib/AkActionView/helpers/cache_helper.php

    r897 r948  
    2424        $this->cache_helper =& $this->controller->cache_helper; 
    2525         
     26        $this->assertIsA($this->cache_helper,'CacheHelper'); 
     27 
     28         
    2629         
    2730    } 
     
    3740        $unitTests = array('_test_cache_with_string_key','_test_cache_with_string_key_cached'); 
    3841         
    39          
     42        if(is_a($this->controller->_CacheHandler,'AkCacheHandler')) { 
    4043        foreach ($cacheHandlers as $class=>$type) { 
    4144            $this->controller->_CacheHandler->_setCacheStore($type); 
     
    4447                $this->$test($class); 
    4548            } 
     49        } 
     50        } else { 
     51            $this->fail('CacheHandler is not initialized. Please enable the caching system for the unit-test'); 
    4652        } 
    4753    } 
  • branches/arnoschn/cache/test/unit/lib/AkCache/AkMemcache.php

    r899 r948  
    1515        $this->memcache=AkCache::lookupStore($cache_settings); 
    1616        $this->assertIsA($this->memcache,'AkCache'); 
     17         
    1718    } 
    1819     
    1920    function test_init_without_server_fallback_to_default() 
    2021    { 
     22         
    2123        $this->memcache=new AkMemcache(); 
    2224        $res = $this->memcache->init(array()); 
     
    4951    function test_set_and_get_string() 
    5052    { 
     53        if (!is_a($this->memcache,'AkCache')) { 
     54            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     55            return; 
     56        } 
    5157        $original = 'test'; 
    5258        $res = $this->memcache->save($original,'test_id_1','strings'); 
     
    5864    function test_set_and_get_integer() 
    5965    { 
     66        if (!is_a($this->memcache,'AkCache')) { 
     67            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     68            return; 
     69        } 
    6070        $original = 1111; 
    6171        $res = $this->memcache->save($original,'test_id_2','integers'); 
     
    6676    function test_set_and_get_float() 
    6777    { 
     78        if (!is_a($this->memcache,'AkCache')) { 
     79            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     80            return; 
     81        } 
    6882        $original = 11.11; 
    6983        $res = $this->memcache->save($original,'test_id_3','floats'); 
     
    7488    function test_set_and_get_array() 
    7589    { 
     90        if (!is_a($this->memcache,'AkCache')) { 
     91            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     92            return; 
     93        } 
    7694        $original = array(0,1,2,3,'test'); 
    7795        $res = $this->memcache->save($original,'test_id_4','arrays'); 
     
    83101    function test_set_and_get_object() 
    84102    { 
     103        if (!is_a($this->memcache,'AkCache')) { 
     104            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     105            return; 
     106        } 
    85107        $original = new stdClass; 
    86108        $original->id = 1; 
     
    94116    function test_set_and_get_objects_within_arrays() 
    95117    { 
     118        if (!is_a($this->memcache,'AkCache')) { 
     119            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     120            return; 
     121        } 
    96122        $obj1=new stdClass; 
    97123        $obj1->id=1; 
     
    109135    function test_set_and_get_large_strings() 
    110136    { 
     137        if (!is_a($this->memcache,'AkCache')) { 
     138            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     139            return; 
     140        } 
    111141        $original = file_get_contents(__FILE__); 
    112142        $res = $this->memcache->save($original,'test_id_7','largestrings'); 
     
    118148    function test_set_and_get_binary_data() 
    119149    { 
     150        if (!is_a($this->memcache,'AkCache')) { 
     151            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     152            return; 
     153        } 
    120154        $original = file_get_contents(AK_BASE_DIR.DS.'public'.DS.'images'.DS.'akelos_framework_logo.png'); 
    121155        $res = $this->memcache->save($original,'test_id_8','binary'); 
     
    127161    function test_set_and_get_really_large_string() 
    128162    { 
     163        if (!is_a($this->memcache,'AkCache')) { 
     164            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     165            return; 
     166        } 
    129167        $original = $this->_generateLargeString(1000000); 
    130168        $res = $this->memcache->save($original,'test_id_9','strings'); 
     
    135173    function test_set_and_get_really_really_large_string() 
    136174    { 
     175        if (!is_a($this->memcache,'AkCache')) { 
     176            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     177            return; 
     178        } 
    137179        $original = $this->_generateLargeString(2000000); 
    138180        $res = $this->memcache->save($original,'test_id_10','strings'); 
     
    144186    function test_set_and_remove_key() 
    145187    { 
     188        if (!is_a($this->memcache,'AkCache')) { 
     189            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     190            return; 
     191        } 
    146192        $original = $this->_generateLargeString(1000); 
    147193        $res = $this->memcache->save($original,'test_id_11','strings'); 
     
    156202    function test_flush_group() 
    157203    { 
     204        if (!is_a($this->memcache,'AkCache')) { 
     205            $this->fail('Caching is not enabled. Please enable caching for the unit test'); 
     206            return; 
     207        } 
    158208        $retrieved = $this->memcache->get('test_id_10','strings'); 
    159209        $this->assertTrue($retrieved!=null);