--- /dev/null
+<?php\r
+if (!defined("_ECRIRE_INC_VERSION")) return;\r
+\r
+ // nom du test\r
+ $test = 'cfg:depot_php';\r
+\r
+ // recherche test.inc qui nous ouvre au monde spip\r
+ $deep = 2;\r
+ $include = '../../tests/test.inc';\r
+ while (!defined('_SPIP_TEST_INC') && $deep++ < 6) {\r
+ $include = '../' . $include;\r
+ @include $include;\r
+ }\r
+ if (!defined('_SPIP_TEST_INC')) {\r
+ die("Pas de $include");\r
+ }\r
+\r
+\r
+### lire_config ###\r
+ \r
+ // les bases de test\r
+ $assoc = array(\r
+ 'one' => 'element 1',\r
+ 'two' => 'element 2',\r
+ 'three' => array('un'=>1, 'deux'=>2, 'troisc'=>"3")\r
+\r
+ );\r
+\r
+### ecrire_config ###\r
+\r
+ $essais = array();\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero', 0);\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc', '0');\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine', 'une chaine'); \r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc', $assoc);\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie', serialize($assoc));\r
+ // chemins\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier', $assoc);\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc', 'trac');\r
+ \r
+ $err = tester_fun('ecrire_config', $essais);\r
+ \r
+ // si le tableau $err est pas vide ca va pas\r
+ if ($err) {\r
+ die ('<b>ecrire_config php</b><dl>' . join('', $err) . '</dl>');\r
+ }\r
+ \r
+### re lire_config ###\r
+\r
+ $essais = array();\r
+ $essais[] = array(0, 'php::tests_cfg_php/test_cfg_zero');\r
+ $essais[] = array('0', 'php::tests_cfg_php/test_cfg_zeroc');\r
+ $essais[] = array('une chaine', 'php::tests_cfg_php/test_cfg_chaine'); \r
+ $essais[] = array($assoc, 'php::tests_cfg_php/test_cfg_assoc');\r
+ $essais[] = array(serialize($assoc), 'php::tests_cfg_php/test_cfg_serie');\r
+ // chemins\r
+ $essais[] = array($assoc + array('truc'=>'trac'), 'php::tests_cfg_php/test_cfg_chemin/casier');\r
+ $essais[] = array('trac', 'php::tests_cfg_php/test_cfg_chemin/casier/truc');\r
+ $essais[] = array(1, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un');\r
+ // chemin pas la\r
+ $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit');\r
+ \r
+ $err = tester_fun('lire_config', $essais);\r
+ \r
+ // si le tableau $err est pas vide ca va pas\r
+ if ($err) {\r
+ die ('<b>relecture ecrire_config php</b><dl>' . join('', $err) . '</dl>');\r
+ }\r
+\r
+### re effacer_config ###\r
+\r
+ $essais = array();\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero');\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc');\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine'); \r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc');\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie');\r
+ // chemins\r
+ // on enleve finement tout test_cfg_chemin : il ne doit rien rester\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit'); // n'existe pas\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/troisc');\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/deux');\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un'); // supprime three\r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/one'); \r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/two'); \r
+ $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc'); // supprimer chemin/casier\r
+\r
+ $err = tester_fun('effacer_config', $essais);\r
+ \r
+ // si le tableau $err est pas vide ca va pas\r
+ if ($err) {\r
+ die ('<b>effacer_config php</b><dl>' . join('', $err) . '</dl>');\r
+ }\r
+\r
+ \r
+### re lire_config ###\r
+\r
+ $essais = array();\r
+ $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zero');\r
+ $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zeroc');\r
+ $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chaine'); \r
+ $essais[] = array(null, 'php::tests_cfg_php/test_cfg_assoc');\r
+ $essais[] = array(null, 'php::tests_cfg_php/test_cfg_serie');\r
+ $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin');\r
+ $essais[] = array(null, 'php::tests_cfg_php');\r
+ \r
+ $err = tester_fun('lire_config', $essais);\r
+ \r
+ // si le tableau $err est pas vide ca va pas\r
+ if ($err) {\r
+ die ('<b>relecture effacer_config php</b><dl>' . join('', $err) . '</dl>');\r
+ }\r
+\r
+ echo "OK";\r
+\r
+?>\r