2 if (!defined("_ECRIRE_INC_VERSION")) return;
5 $test = 'cfg:depot_php';
7 // recherche test.inc qui nous ouvre au monde spip
9 $include = '../../tests/test.inc';
10 while (!defined('_SPIP_TEST_INC') && $deep++
< 6) {
11 $include = '../' . $include;
14 if (!defined('_SPIP_TEST_INC')) {
15 die("Pas de $include");
25 'three' => array('un'=>1, 'deux'=>2, 'troisc'=>"3")
32 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero', 0);
33 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc', '0');
34 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine', 'une chaine');
35 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc', $assoc);
36 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie', serialize($assoc));
38 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier', $assoc);
39 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc', 'trac');
41 $err = tester_fun('ecrire_config', $essais);
43 // si le tableau $err est pas vide ca va pas
45 die ('<b>ecrire_config php</b><dl>' . join('', $err) . '</dl>');
48 ### re lire_config ###
51 $essais[] = array(0, 'php::tests_cfg_php/test_cfg_zero');
52 $essais[] = array('0', 'php::tests_cfg_php/test_cfg_zeroc');
53 $essais[] = array('une chaine', 'php::tests_cfg_php/test_cfg_chaine');
54 $essais[] = array($assoc, 'php::tests_cfg_php/test_cfg_assoc');
55 $essais[] = array(serialize($assoc), 'php::tests_cfg_php/test_cfg_serie');
57 $essais[] = array($assoc +
array('truc'=>'trac'), 'php::tests_cfg_php/test_cfg_chemin/casier');
58 $essais[] = array('trac', 'php::tests_cfg_php/test_cfg_chemin/casier/truc');
59 $essais[] = array(1, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un');
61 $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit');
63 $err = tester_fun('lire_config', $essais);
65 // si le tableau $err est pas vide ca va pas
67 die ('<b>relecture ecrire_config php</b><dl>' . join('', $err) . '</dl>');
70 ### re effacer_config ###
73 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero');
74 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc');
75 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine');
76 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc');
77 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie');
79 // on enleve finement tout test_cfg_chemin : il ne doit rien rester
80 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit'); // n'existe pas
81 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/troisc');
82 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/deux');
83 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un'); // supprime three
84 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/one');
85 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/two');
86 $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc'); // supprimer chemin/casier
88 $err = tester_fun('effacer_config', $essais);
90 // si le tableau $err est pas vide ca va pas
92 die ('<b>effacer_config php</b><dl>' . join('', $err) . '</dl>');
96 ### re lire_config ###
99 $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zero');
100 $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zeroc');
101 $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chaine');
102 $essais[] = array(null, 'php::tests_cfg_php/test_cfg_assoc');
103 $essais[] = array(null, 'php::tests_cfg_php/test_cfg_serie');
104 $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin');
105 $essais[] = array(null, 'php::tests_cfg_php');
107 $err = tester_fun('lire_config', $essais);
109 // si le tableau $err est pas vide ca va pas
111 die ('<b>relecture effacer_config php</b><dl>' . join('', $err) . '</dl>');