source: trunk/spip/esqueleto-redcta/plugins/cfg/tests/depot_php.php @ 152

Last change on this file since 152 was 152, checked in by guille, 15 years ago

se agregaron svn_update y cfg para el 2.0

File size: 4.0 KB
Line 
1<?php
2
3        // nom du test
4        $test = 'cfg:depot_php';
5
6        // recherche test.inc qui nous ouvre au monde spip
7        $deep = 2;
8        $include = '../../tests/test.inc';
9        while (!defined('_SPIP_TEST_INC') && $deep++ < 6) {
10                $include = '../' . $include;
11                @include $include;
12        }
13        if (!defined('_SPIP_TEST_INC')) {
14                die("Pas de $include");
15        }
16
17
18### lire_config ###
19       
20        // les bases de test
21        $assoc = array(
22                'one' => 'element 1',
23                'two' => 'element 2',
24                'three' => array('un'=>1, 'deux'=>2, 'troisc'=>"3")
25
26        );
27
28### ecrire_config ###
29
30        $essais = array();
31        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero', 0);
32        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc', '0');
33        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine', 'une chaine');           
34        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc', $assoc);
35        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie', serialize($assoc));
36        // chemins
37        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier', $assoc);
38        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc', 'trac');
39       
40        $err = tester_fun('ecrire_config', $essais);
41       
42        // si le tableau $err est pas vide ca va pas
43        if ($err) {
44                die ('<b>ecrire_config php</b><dl>' . join('', $err) . '</dl>');
45        }
46       
47### re lire_config ###
48
49        $essais = array();
50        $essais[] = array(0, 'php::tests_cfg_php/test_cfg_zero');
51        $essais[] = array('0', 'php::tests_cfg_php/test_cfg_zeroc');
52        $essais[] = array('une chaine', 'php::tests_cfg_php/test_cfg_chaine');         
53        $essais[] = array($assoc, 'php::tests_cfg_php/test_cfg_assoc');
54        $essais[] = array(serialize($assoc), 'php::tests_cfg_php/test_cfg_serie');
55        // chemins
56        $essais[] = array($assoc + array('truc'=>'trac'), 'php::tests_cfg_php/test_cfg_chemin/casier');
57        $essais[] = array('trac', 'php::tests_cfg_php/test_cfg_chemin/casier/truc');
58        $essais[] = array(1, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un');
59        // chemin pas la
60        $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit');
61       
62        $err = tester_fun('lire_config', $essais);
63       
64        // si le tableau $err est pas vide ca va pas
65        if ($err) {
66                die ('<b>relecture ecrire_config php</b><dl>' . join('', $err) . '</dl>');
67        }
68
69### re effacer_config ###
70
71        $essais = array();
72        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zero');
73        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_zeroc');
74        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chaine');         
75        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_assoc');
76        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_serie');
77        // chemins
78        // on enleve finement tout test_cfg_chemin : il ne doit rien rester
79        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/huit'); // n'existe pas
80        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/troisc');
81        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/deux');
82        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/three/un'); // supprime three
83        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/one'); 
84        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/two'); 
85        $essais[] = array(true, 'php::tests_cfg_php/test_cfg_chemin/casier/truc'); // supprimer chemin/casier
86
87        $err = tester_fun('effacer_config', $essais);
88       
89        // si le tableau $err est pas vide ca va pas
90        if ($err) {
91                die ('<b>effacer_config php</b><dl>' . join('', $err) . '</dl>');
92        }
93
94       
95### re lire_config ###
96
97        $essais = array();
98        $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zero');
99        $essais[] = array(null, 'php::tests_cfg_php/test_cfg_zeroc');
100        $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chaine');         
101        $essais[] = array(null, 'php::tests_cfg_php/test_cfg_assoc');
102        $essais[] = array(null, 'php::tests_cfg_php/test_cfg_serie');
103        $essais[] = array(null, 'php::tests_cfg_php/test_cfg_chemin');
104        $essais[] = array(null, 'php::tests_cfg_php');
105       
106        $err = tester_fun('lire_config', $essais);
107       
108        // si le tableau $err est pas vide ca va pas
109        if ($err) {
110                die ('<b>relecture effacer_config php</b><dl>' . join('', $err) . '</dl>');
111        }
112
113        echo "OK";
114
115?>
Note: See TracBrowser for help on using the repository browser.