source: sandbox/filemanager/tests/test.php @ 1506

Revision 1506, 11.2 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Adicionando código do filemanager compatível com expresso

Line 
1<?php
2
3$phpgw_info["flags"] = array("currentapp" => "filemanager",
4                                "noheader" => False,
5                                "noappheader" => False,
6                                "enable_vfs_class" => True);
7
8include("../header.inc.php");
9
10/*
11        General format for output is:
12        sequence number - function - current directory - input[...] - what output should be - what output was
13*/
14
15html_break (1);
16html_text_italic (PHP_OS . " - " . $phpgw_info["server"]["db_type"] . " - " . PHP_VERSION . " - " . $phpgw->vfs->basedir);
17html_break (1);
18
19$sep = SEP;
20$user = $phpgw->vfs->working_lid;
21$homedir = $phpgw->vfs->fakebase . "/" . $user;
22$realhomedir = preg_replace ("|/|", $sep, $homedir);
23$filesdir = $phpgw->vfs->basedir;
24$currentapp = $phpgw_info["flags"]["currentapp"];
25
26###
27# start of getabsolutepath tests
28
29$sequence_num = 1;
30$phpgw->vfs->cd ();
31$io = array ("" => "$homedir", "dir" => "$homedir/dir", "dir/file" => "$homedir/dir/file", "dir/dir2" => "$homedir/dir/dir2", "dir/dir2/file" => "$homedir/dir/dir2/file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "$homedir/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?");
32
33while (list ($i, $o) = each ($io))
34{
35        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i))) != $o)
36        {
37                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $o - $ao";
38        }
39}
40
41$sequence_num = 2;
42$cd = "test";
43$phpgw->vfs->cd (array(
44                'string'        => $cd,
45                'relative'      => False,
46                'relatives'     => array (RELATIVE_NONE)
47        )
48);
49$io = array ("" => "/test", "dir" => "/test/dir", "dir/file" => "/test/dir/file", "dir/dir2" => "/test/dir/dir2", "dir/dir2/file" => "/test/dir/dir2/file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "/test/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?");
50
51while (list ($i, $o) = each ($io))
52{
53        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i))) != $o)
54        {
55                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $o - $ao";
56        }
57}
58
59$sequence_num = 3;
60$cd = "test/test2/test3";
61$phpgw->vfs->cd (array(
62                'string'        => $cd,
63                'relative'      => False,
64                'relatives'     => array (RELATIVE_NONE)
65        )
66);
67$io = array ("" => "/test/test2/test3", "dir" => "/test/test2/test3/dir", "dir/file" => "/test/test2/test3/dir/file", "dir/dir2" => "/test/test2/test3/dir/dir2", "dir/dir2/file" => "/test/test2/test3/dir/dir2/file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "/test/test2/test3/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?");
68
69while (list ($i, $o) = each ($io))
70{
71        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i))) != $o)
72        {
73                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $o - $ao";
74        }
75}
76
77/* Actually means cd to home directory */
78$sequence_num = 4;
79$cd = "";
80$phpgw->vfs->cd (array(
81                'string'        => $cd
82        )
83);
84$relatives = array (RELATIVE_USER);
85$io = array ("" => "$homedir", "dir" => "$homedir/dir", "dir/file" => "$homedir/dir/file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "$homedir/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?");
86
87while (list ($i, $o) = each ($io))
88{
89        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives))) != $o)
90        {
91                echo '<br><b>HERE</b>';
92                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $relatives[0] - $o - $ao";
93        }
94}
95
96/* $cd shouldn't affect this test, but we'll set it anyways */
97$sequence_num = 5;
98$cd = "test2/test4";
99$phpgw->vfs->cd (array(
100                'string'        => $cd,
101                'relative'      => False,
102                'relatives'     => array (RELATIVE_NONE)
103        )
104);
105$relatives = array (RELATIVE_NONE);
106$io = array ("" => "", "dir" => "dir", "dir/file" => "dir/file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?");
107
108while (list ($i, $o) = each ($io))
109{
110        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives))) != $o)
111        {
112                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't matter) - $i - $relatives[0] - $o - $ao";
113        }
114}
115
116/* $cd shouldn't affect this test, but we'll set it anyways */
117$sequence_num = 6;
118$cd = "test3/test5";
119$phpgw->vfs->cd (array(
120                'string'        => $cd,
121                'relative'      => False,
122                'relatives'     => array (RELATIVE_NONE)
123        )
124);
125$relatives = array (RELATIVE_USER_APP);
126$io = array ("" => "$homedir/.$currentapp", "dir" => "$homedir/.$currentapp/dir", "dir/dir2" => "$homedir/.$currentapp/dir/dir2", "dir/file" => "$homedir/.$currentapp/dir/file", "dir/dir2/dir3/file" => "$homedir/.$currentapp/dir/dir2/dir3/file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "$homedir/.$currentapp/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?");
127
128while (list ($i, $o) = each ($io))
129{
130        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives))) != $o)
131        {
132                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't matter) - $i - $relatives[0] - $o - $ao";
133        }
134}
135
136/* $cd shouldn't affect this test, but we'll set it anyways */
137$sequence_num = 7;
138$cd = "test4/test6";
139$phpgw->vfs->cd (array(
140                'string'        => $cd,
141                'relative'      => False,
142                'relatives'     => array (RELATIVE_NONE)
143        )
144);
145$relatives = array (RELATIVE_ROOT);
146$io = array ("" => "", "dir" => "/dir", "/dir/dir2/dir3" => "/dir/dir2/dir3", "dir/file" => "/dir/file", "dir/dir2/dir3" => "/dir/dir2/dir3", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?");
147
148while (list ($i, $o) = each ($io))
149{
150        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives))) != $o)
151        {
152                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't matter) - $i - $relatives[0] - $o - $ao";
153        }
154}
155
156/* Now a few to test the VFS_REAL capabilities */
157$sequence_num = 8;
158$cd = "";
159$phpgw->vfs->cd (array(
160                'string'        => $cd,
161                'relative'      => False,
162                'relatives'     => array (RELATIVE_NONE)
163        )
164);
165$relatives = array (RELATIVE_ROOT|VFS_REAL);
166$io = array ("" => "$filesdir", "dir" => "$filesdir$sep" . "dir", "dir/dir2/dir3" => "$filesdir$sep" . "dir$sep" . "dir2$sep" . "dir3", "dir/file" => "$filesdir$sep" . "dir$sep" . "file", "dir/dir2/dir3/file" => "$filesdir$sep" . "dir$sep" . "dir2$sep" . "dir3$sep" . "file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "$filesdir$sep" . "`~!@#$%^&*()-_=+$sep" . "|[{]};:'\",<.>?");
167
168while (list ($i, $o) = each ($io))
169{
170        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives, 'fake' =>False))) != $o)
171        {
172                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't matter) - $i - $relatives[0] - $o - $ao";
173        }
174}
175
176$sequence_num = 9;
177$cd = "test5/test7";
178$phpgw->vfs->cd (array(
179                'string'        => $cd,
180                'relative'      => False,
181                'relatives'     => array (RELATIVE_NONE)
182        )
183);
184$relatives = array (RELATIVE_USER|VFS_REAL);
185$io = array ("" => "$filesdir$realhomedir", "dir" => "$filesdir$realhomedir$sep" . "dir", "dir/dir2/dir3" => "$filesdir$realhomedir$sep" . "dir$sep" . "dir2$sep" . "dir3", "dir/file" => "$filesdir$realhomedir$sep" . "dir$sep" . "file", "dir/dir2/dir3/file" => "$filesdir$realhomedir$sep" . "dir$sep" . "dir2$sep" . "dir3$sep" . "file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "$filesdir$realhomedir$sep" . "`~!@#$%^&*()-_=+$sep" . "|[{]};:'\",<.>?");
186
187while (list ($i, $o) = each ($io))
188{
189        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives, 'fake' => False))) != $o)
190        {
191                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't matter) - $i - $relatives[0] - $o - $ao";
192        }
193}
194
195$sequence_num = 10;
196$cd = "test6/test8";
197$phpgw->vfs->cd (array(
198                'string'        => $cd,
199                'relative'      => False,
200                'relatives'     => array (RELATIVE_USER)
201        )
202);
203/* RELATIVE_CURRENT should be implied */
204$relatives = array (VFS_REAL);
205$io = array ("" => "$filesdir$realhomedir$sep$cd", "dir" => "$filesdir$realhomedir$sep$cd$sep" . "dir", "dir/dir2/dir3" => "$filesdir$realhomedir$sep$cd$sep" . "dir$sep" . "dir2$sep" . "dir3", "dir/file" => "$filesdir$realhomedir$sep$cd$sep" . "dir$sep" . "file", "dir/dir2/dir3/file" => "$filesdir$realhomedir$sep$cd$sep" . "dir$sep" . "dir2$sep" . "dir3$sep" . "file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "$filesdir$realhomedir$sep$cd$sep" . "`~!@#$%^&*()-_=+$sep" . "|[{]};:'\",<.>?");
206
207while (list ($i, $o) = each ($io))
208{
209        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives, 'fake' => False))) != $o)
210        {
211                echo "<br>$sequence_num - getabsolutepath - $cd - $i - $relatives[0] - $o - $ao";
212        }
213}
214
215$sequence_num = 11;
216$cd = "test7/test9";
217$phpgw->vfs->cd (array(
218                'string'        => $cd,
219                'relative'      => False,
220                'relatives'     => array (RELATIVE_USER)
221        )
222);
223$relatives = array (RELATIVE_USER_APP|VFS_REAL);
224$io = array ("" => "$filesdir$realhomedir$sep.$currentapp", "dir" => "$filesdir$realhomedir$sep.$currentapp$sep" . "dir", "dir/dir2/dir3" => "$filesdir$realhomedir$sep.$currentapp$sep" . "dir$sep" . "dir2$sep" . "dir3", "dir/file" => "$filesdir$realhomedir$sep.$currentapp$sep" . "dir$sep" . "file", "dir/dir2/dir3/file" => "$filesdir$realhomedir$sep.$currentapp$sep" . "dir$sep" . "dir2$sep" . "dir3$sep" . "file", "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => "$filesdir$realhomedir$sep.$currentapp$sep`~!@#$%^&*()-_=+$sep" . "|[{]};:'\",<.>?");
225
226while (list ($i, $o) = each ($io))
227{
228        if (($ao = $phpgw->vfs->getabsolutepath (array ('string' => $i, 'mask' => $relatives, 'fake' => False))) != $o)
229        {
230                echo "<br>$sequence_num - getabsolutepath - $cd (shouldn't matter) - $i - $relatives[0] - $o - $ao";
231        }
232}
233
234# end of getabsolutepath tests
235###
236
237###
238# start of path_parts tests
239
240/* Just for convienience
241$io = array ("" => array ("fake_full_path" => "", "fake_leading_dirs" => "", "fake_extra_path" => "", "fake_name" => "", "real_full_path" => "", "real_leading_dirs" => "", "real_extra_path" => "", "real_name" => ""));
242`~!@#$%^&*()-_=+/|[{]};:'\",<.>?
243*/
244
245$sequence_num = 12;
246$cd = "test8/test10";
247$relatives[0] = RELATIVE_USER;
248$phpgw->vfs->cd (array(
249                'string'        => $cd,
250                'relative'      => False,
251                'relatives'     => array ($relatives[0])
252        )
253);
254$subhome = substr ($homedir, 1);
255$io = array ("" => array ("fake_full_path" => "$homedir/$cd", "fake_leading_dirs" => "$homedir/test8", "fake_extra_path" => "$subhome/test8", "fake_name" => "test10", "real_full_path" => "$filesdir$homedir/$cd", "real_leading_dirs" => "$filesdir$homedir/test8", "real_extra_path" => "$subhome/test8", "real_name" => "test10"), "dir2/file" => array ("fake_full_path" => "$homedir/$cd/dir2/file", "fake_leading_dirs" => "$homedir/$cd/dir2", "fake_extra_path" => "$subhome/$cd/dir2", "fake_name" => "file", "real_full_path" => "$filesdir$homedir/$cd/dir2/file", "real_leading_dirs" => "$filesdir$homedir/$cd/dir2", "real_extra_path" => "$subhome/$cd/dir2", "real_name" => "file"), "`~!@#$%^&*()-_=+/|[{]};:'\",<.>?" => array ("fake_full_path" => "$homedir/$cd/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?", "fake_leading_dirs" => "$homedir/$cd/`~!@#$%^&*()-_=+", "fake_extra_path" => "$subhome/$cd/`~!@#$%^&*()-_=+", "fake_name" => "|[{]};:'\",<.>?", "real_full_path" => "$filesdir$homedir/$cd/`~!@#$%^&*()-_=+/|[{]};:'\",<.>?", "real_leading_dirs" => "$filesdir$homedir/$cd/`~!@#$%^&*()-_=+", "real_extra_path" => "$subhome/$cd/`~!@#$%^&*()-_=+", "real_name" => "|[{]};:'\",<.>?"));
256
257while (list ($i, $o) = each ($io))
258{
259        $ao = $phpgw->vfs->path_parts (array ('string' => $i));
260        while (list ($key, $value) = each ($o))
261        {
262                if ($ao->$key != $o[$key])
263                {
264                        echo "<br>$sequence_num - path_parts - $cd - $i - $relatives[0] - $key - $o[$key] - $ao[$key]";
265                }
266        }
267}
268
269# end of path_parts tests
270###
271
272$phpgw->vfs->cd ();
273
274html_break (2);
275html_text_bold ("The less output, the better.  Please file errors as a " . html_link ("https://sourceforge.net/tracker/?group_id=7305&atid=107305", "bug report", True, False) .  ". Be sure to include the system information line at the top, and anything special about your setup.  Thanks!");
276
277html_page_close ();
278
279?>
Note: See TracBrowser for help on using the repository browser.