X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fplugins%2Fauto%2Fcfg%2Ftests%2Fdepot_php.php;fp=www%2Fplugins%2Fauto%2Fcfg%2Ftests%2Fdepot_php.php;h=f763ee250a466ff86f63b02fdf1f020a1adc85e4;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/plugins/auto/cfg/tests/depot_php.php b/www/plugins/auto/cfg/tests/depot_php.php new file mode 100644 index 0000000..f763ee2 --- /dev/null +++ b/www/plugins/auto/cfg/tests/depot_php.php @@ -0,0 +1,116 @@ + 'element 1', + 'two' => 'element 2', + 'three' => array('un'=>1, 'deux'=>2, 'troisc'=>"3") + + ); + +### ecrire_config ### + + $essais = array(); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero', 0); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc', '0'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine', 'une chaine'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc', $assoc); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie', serialize($assoc)); + // chemins + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier', $assoc); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc', 'trac'); + + $err = tester_fun('ecrire_config', $essais); + + // si le tableau $err est pas vide ca va pas + if ($err) { + die ('ecrire_config php
' . join('', $err) . '
'); + } + +### re lire_config ### + + $essais = array(); + $essais[] = array(0, 'php::tests_cfg_php/test_cfg_zero'); + $essais[] = array('0', 'php::tests_cfg_php/test_cfg_zeroc'); + $essais[] = array('une chaine', 'php::tests_cfg_php/test_cfg_chaine'); + $essais[] = array($assoc, 'php::tests_cfg_php/test_cfg_assoc'); + $essais[] = array(serialize($assoc), 'php::tests_cfg_php/test_cfg_serie'); + // chemins + $essais[] = array($assoc + array('truc'=>'trac'), 'php::tests_cfg_php/test_cfg_chemin/casier'); + $essais[] = array('trac', 'php::tests_cfg_php/test_cfg_chemin/casier/truc'); + $essais[] = array(1, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un'); + // chemin pas la + $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit'); + + $err = tester_fun('lire_config', $essais); + + // si le tableau $err est pas vide ca va pas + if ($err) { + die ('relecture ecrire_config php
' . join('', $err) . '
'); + } + +### re effacer_config ### + + $essais = array(); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie'); + // chemins + // on enleve finement tout test_cfg_chemin : il ne doit rien rester + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit'); // n'existe pas + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/troisc'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/deux'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un'); // supprime three + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/one'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/two'); + $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc'); // supprimer chemin/casier + + $err = tester_fun('effacer_config', $essais); + + // si le tableau $err est pas vide ca va pas + if ($err) { + die ('effacer_config php
' . join('', $err) . '
'); + } + + +### re lire_config ### + + $essais = array(); + $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zero'); + $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zeroc'); + $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chaine'); + $essais[] = array(null, 'php::tests_cfg_php/test_cfg_assoc'); + $essais[] = array(null, 'php::tests_cfg_php/test_cfg_serie'); + $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin'); + $essais[] = array(null, 'php::tests_cfg_php'); + + $err = tester_fun('lire_config', $essais); + + // si le tableau $err est pas vide ca va pas + if ($err) { + die ('relecture effacer_config php
' . join('', $err) . '
'); + } + + echo "OK"; + +?>