]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/unit/test.php
some convenience
[SourceForge/phpwiki.git] / tests / unit / test.php
1 <?php // #!/usr/local/bin/php -Cq
2 /* Copyright (C) 2004 Dan Frankowski <dfrankow@cs.umn.edu>
3  * Copyright (C) 2004 Reini Urban <rurban@x-ray.at>
4  *
5  * This file is part of PhpWiki.
6  * 
7  * PhpWiki is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  * 
12  * PhpWiki is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with PhpWiki; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 /**
23  * Unit tests for PhpWiki. 
24  *
25  * You must have PEAR's PHPUnit package <http://pear.php.net/package/PHPUnit>. 
26  * These tests are unrelated to test/maketest.pl, which do not use PHPUnit.
27  * These tests run from the command-line as well as from the browser.
28  * Use the argv (from cli) or tests (from browser) params to run only certain tests.
29  *
30  * $ tests.php test=<testname1> test=<testname2> ... db=dba debug=9 level=10
31  */
32 /****************************************************************
33    User definable options
34 *****************************************************************/
35 // common cfg options are taken from config/config.ini
36
37 //TODO: let the user decide which constants to use: define="x=y"
38 //define('USE_DB_SESSION', false);
39 //define('ENABLE_USER_NEW', false);
40
41 // memory usage: (8MB limit on certain servers)
42 // setupwiki
43 // cli:  Mem16712 => Mem16928
44 // web:  Mem21216 => Mem26332 (5MB)
45
46 // dumphtml:
47 // cli: Mem20696 => Mem31240  (with USECACHE)    (10MB)
48 // cli: Mem20240 => Mem30212  (without USECACHE) (10MB)
49 // web: Mem29424 => Mem35400  (without USECACHE) (6MB)
50 //define('USECACHE', false);
51
52 ####################################################################
53 #
54 # Preamble needed to get the tests to run.
55 #
56 ####################################################################
57
58 $cur_dir = getcwd();
59 # Add root dir to the path
60 if (substr(PHP_OS,0,3) == 'WIN')
61     $cur_dir = str_replace("\\","/", $cur_dir);
62 $rootdir = $cur_dir . '/../../';
63 $ini_sep = substr(PHP_OS,0,3) == 'WIN' ? ';' : ':';
64 $include_path = ini_get('include_path') . $ini_sep . $rootdir . $ini_sep . $rootdir . "lib/pear";
65 ini_set('include_path', $include_path);
66 define('DEFAULT_LANGUAGE','en'); // don't use browser detection
67
68 if (!empty($HTTP_SERVER_VARS) and $HTTP_SERVER_VARS["SERVER_NAME"] == 'phpwiki.sourceforge.net') {
69     ini_set('include_path', ini_get('include_path') . ":/usr/share/pear");
70     //define('ENABLE_PAGEPERM',false); // costs nothing
71     define('USECACHE',false); // really?
72     //define('WIKIDB_NOCACHE_MARKUP',1);
73 }
74
75 // available database backends to test:
76 $database_backends = array(
77                            'file',
78                            'dba',
79                            'SQL',
80                            'ADODB',
81                            );
82 //TODO: convert cvs test                           
83 //TODO: read some database values from config.ini, just use the "test_" prefix
84 // "flatfile" testing occurs in "tests/unit/.testbox/"
85 // "dba" needs the DATABASE_DBA_HANDLER, also in the .textbox directory
86 //$database_dba_handler = (substr(PHP_OS,0,3) == 'WIN') ? "db3" : "gdbm";
87 // "SQL" and "ADODB" need delete permissions to the test db
88 //  You have to create that database beforehand with our schema
89 //$database_dsn = "mysql://wikiuser:@localhost/phpwiki";
90 $database_prefix = "test_";
91 // For "cvs" see the seperate tests/unit_test_backend_cvs.php
92
93 # Quiet warnings in IniConfig.php
94 $HTTP_SERVER_VARS['REMOTE_ADDR'] = '127.0.0.1';
95 $HTTP_SERVER_VARS['HTTP_USER_AGENT'] = "PHPUnit";
96
97 function printMemoryUsage($msg = '') {
98     static $mem = 0;
99     static $initmem = 0;
100     if ($msg) echo $msg,"\n";
101     if ((defined('DEBUG') and (DEBUG & 8)) or !defined('DEBUG')) {
102         echo "-- MEMORY USAGE: ";
103         $oldmem = $mem;
104         if (function_exists('memory_get_usage') and memory_get_usage()) {
105             $mem = memory_get_usage();
106             //        } elseif (function_exists('getrusage') and ($u = getrusage()) and !empty($u['ru_maxrss'])) {
107             //            $mem = $u['ru_maxrss'];
108         } elseif (substr(PHP_OS,0,3)=='WIN') { // requires a newer cygwin
109             // what we want is the process memory only: apache or php
110             $pid = getmypid();
111             // This works only if it's a cygwin process (apache or php)
112             //$mem = (integer) trim(system("cat /proc/$pid/statm |cut -f1"));
113             // if it's native windows use something like this: 
114             //   (requires pslist from sysinternals.com)
115             $memstr = system("pslist $pid|grep -A1 Mem|sed 1d|perl -ane\"print \$"."F[5]\"");
116             $mem = (integer) trim($memstr);
117         } else {
118             $pid = getmypid();
119             //%MEM: Percentage of total memory in use by this process
120             //VSZ: Total virtual memory size, in 1K blocks.
121             //RSS: Real Set Size, the actual amount of physical memory allocated to this process.
122             //CPU time used by process since it started.
123             //echo "%",`ps -o%mem,vsz,rss,time -p $pid|sed 1d`,"\n";
124             $memstr = system("ps -orss -p $pid|sed 1d");
125             $mem = (integer) trim($memstr);
126         }
127         if (!$initmem) $initmem = $mem;
128         // old libc on sf.net server doesn't understand "%+4d"
129         echo sprintf("%8d\t[%s%4d]\t[+%4d]\n", $mem, $mem > $oldmem ? "+" : ($mem == $oldmem ? " " : ""), $mem - $oldmem, $mem - $initmem);
130         // TODO: print time
131         flush();
132     }
133 }
134 /* // now in stdlib.php
135 function printSimpleTrace($bt) {
136     //print_r($bt);
137     echo "Traceback:\n";
138     foreach ($bt as $i => $elem) {
139         if (!array_key_exists('file', $elem)) {
140             continue;
141         }
142         print "  " . $elem['file'] . ':' . $elem['line'] . "\n";
143     }
144 }
145 */
146 # Show lots of detail when an assert() in the code fails
147 function assert_callback( $script, $line, $message ) {
148    echo "assert failed: script ", $script," line ", $line," :";
149    echo "$message";
150    if (function_exists('debug_backtrace')) { // >= 4.3.0
151        echo "Traceback:\n";
152        printSimpleTrace(debug_backtrace());
153    }
154    exit;
155 }
156 $foo = assert_options( ASSERT_CALLBACK, 'assert_callback');
157
158 #
159 # Get error reporting to call back, too
160 #
161 // set the error reporting level for this script
162 if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5?
163     error_reporting(E_ALL & ~E_STRICT);         // exclude E_STRICT
164 else
165     error_reporting(E_ALL); // php4
166
167 // This is too strict, fails on every notice and warning. 
168 /*
169 function myErrorHandler$errno, $errstr, $errfile, $errline) {
170    echo "$errfile: $errline: error# $errno: $errstr\n";
171    echo "Traceback:\n";
172    printSimpleTrace(debug_backtrace());
173 }
174 // The ErrorManager version
175 function _ErrorHandler_CB(&$error) {
176    echo "Traceback:\n";
177    printSimpleTrace(debug_backtrace());
178    if ($error->isFatal()) {
179         $error->errno = E_USER_WARNING;
180         return true; // ignore error
181    }
182    return true;
183 }
184 // set to the user defined error handler
185 // $old_error_handler = set_error_handler("myErrorHandler");
186 // This is already done via _DEBUG_TRACE
187 //$ErrorManager->pushErrorHandler(new WikiFunctionCb('_ErrorHandler_CB'));
188 */
189
190 function purge_dir($dir) {
191     static $finder;
192     if (!isset($finder)) {
193         $finder = new FileFinder;
194     }
195     $fileSet = new fileSet($dir);
196     assert(!empty($dir));
197     foreach ($fileSet->getFiles() as $f) {
198         unlink("$dir/$f");
199     }
200 }
201
202 function purge_testbox() {
203     global $DBParams;   
204     if (isset($GLOBALS['request'])) {
205         $dbi = $GLOBALS['request']->getDbh();
206     }
207     $dir = $DBParams['directory'];
208     switch ($DBParams['dbtype']) {
209     case 'file':
210         assert(!empty($dir));
211         foreach (array('latest_ver','links','page_data','ver_data') as $d) {
212             purge_dir("$dir/$d");
213         }
214         break;
215     case 'SQL':
216     case 'ADODB':
217         foreach ($dbi->_backend->_table_names as $table) {
218             $dbi->genericSqlQuery("DELETE FROM $table");
219         }
220         break;
221     case 'dba':
222         purge_dir($dir);
223         break;
224     }
225     if (isset($dbi)) {
226         $dbi->_cache->close();
227         $dbi->_backend->_latest_versions = array();
228     }
229 }
230
231 function printConstant($v) {
232     echo "$v=";
233     if (defined($v)) {
234         if (constant($v) or constant($v)===0 or constant($v)==='0') echo constant($v);
235         else echo "false";
236     } else echo "undefined";
237     echo "\n";
238 }
239 /**
240  * via the HTML sapi interface print a form to easily change the current cmdline settings.
241  */
242 function html_option_form() {
243     global $debug_level, $user_level, $start_debug;
244
245     $form = HTML();
246     $option = HTML::div(array('class' => 'option'), 
247                         HTML::span(array('style'=>'font-weight: bold','onDblClick'=>'flipAll(\'test[\')'), 'test: '),
248                         HTML::br());
249     foreach ($GLOBALS['alltests'] as $s) {
250         $input = array('type' => 'checkbox', 'name' => 'test['.$s.']', 'value' => '1');
251         if (in_array($s,$GLOBALS['runtests'])) $input['checked'] = 'checked';
252         $option->pushContent(HTML::input($input), $s, HTML::br());
253     }
254     $form->pushContent(HTML::td($option));
255
256     $option = HTML::div(array('class' => 'option'), 
257                         HTML::span(array('style'=>'font-weight: bold','onDblClick'=>'flipAll(\'db[\')'), 'db: '),
258                         HTML::br());
259     foreach ($GLOBALS['database_backends'] as $s) {
260         $input = array('type' => 'checkbox', 'name' => 'db['.$s.']', 'value' => '1');
261         if (in_array($s,$GLOBALS['run_database_backends'])) $input['checked'] = 'checked';
262         $option->pushContent(HTML::input($input), $s, HTML::br());
263     }
264     $form->pushContent(HTML::td($option));
265
266     $js = JavaScript(
267 "function flipAll(formName) {
268   var isFirstSet = -1;
269   formObj = document.forms[0];
270   for (var i=0; i < formObj.length; i++) {
271       fldObj = formObj.elements[i];
272       if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,formName.length) == formName)) { 
273          if (isFirstSet == -1)
274            isFirstSet = (fldObj.checked) ? true : false;
275          fldObj.checked = (isFirstSet) ? false : true;
276        }
277    }
278 }
279 function updateDebugEdit(formObj) {
280   val=0;
281   for (var i=0; i < formObj.length; i++) {
282       fldObj = formObj.elements[i];
283       if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,7) == '_debug[')) { 
284          if (fldObj.checked) val = val + parseInt(fldObj.value);
285        }
286    }
287    formObj.debug.value = val;
288 }
289 function updateLevelEdit(formObj) {
290   for (var i=0; i < formObj.length; i++) {
291       fldObj = formObj.elements[i];
292       if ((fldObj.type == 'radio') && (fldObj.name.substring(0,7) == '_level[')) {
293          if (fldObj.checked) {
294             formObj.level.value = fldObj.value;
295             return;
296          }
297       }
298    }
299 }");
300     $option = HTML::div(array('class' => 'option'),
301                         HTML::span(array('style'=>'font-weight: bold','onDblClick'=>'flipAll(\'_debug[\')'), 'debug: '),
302                         HTML::input(array('name'=>'debug','id'=>'debug','value'=>$debug_level,'size'=>5)),
303                         HTML::br());
304     foreach (array('VERBOSE'    => 1,
305                    'PAGELINKS'  => 2,
306                    'PARSER'     => 4,
307                    'TRACE'      => 8,
308                    'INFO'       => 16,
309                    'APD'        => 32,
310                    'LOGIN'      => 64,
311                    'SQL'        => 128,
312                    ) as $s => $v) {
313         $input = array('type' => 'checkbox', 'name' => '_debug[]', 'value' => $v, 
314                        'onClick' => 'updateDebugEdit(this.form)');
315         if ($debug_level & $v) $input['checked'] = 'checked';
316         $option->pushContent(HTML::input($input), "_DEBUG_".$s, HTML::br());
317     }
318     $form->pushContent(HTML::td($option));
319
320     $option = HTML::div(array('class' => 'option'), 
321                         HTML::span(array('style'=>'font-weight: bold'), "level: "),
322                         HTML::input(array('name'=>'level','id'=>'level','value'=>$user_level,'size'=>5)),
323                         HTML::br());
324     foreach (array('FORBIDDEN'  => -1,
325                    'ANON'       => 0,
326                    'BOGO'       => 1,
327                    'USER'       => 2,
328                    'ADMIN'      => 10,
329                    'UNOBTAINABLE'=> 100,
330                    ) as $s => $v) {
331         $input = array('type' => 'radio', 'name' => '_level[]', 'value' => $v,
332                        'onClick' => 'updateLevelEdit(this.form)');
333         if ($user_level & $v) $input['checked'] = 'checked';
334         $option->pushContent(HTML::input($input), "WIKIAUTH_".$s, HTML::br());
335     }
336     $form->pushContent(HTML::td($option));
337
338     unset($input);
339     $option = HTML::div(array('class' => 'option'), 'defines: ', HTML::br());
340     if (!empty($GLOBALS['define']))
341       foreach ($GLOBALS['define'] as $s) {
342         if (defined($s)) {
343             $input = array('type' => 'edit', 'name' => $s, 'value' => constant($s));
344             $option->pushContent(HTML::input($input), $s, HTML::br());
345         }
346     }
347     if (!empty($input))
348         $form->pushContent(HTML::td($option));
349     $table = HTML::form(array('action' => $_SERVER['PHP_SELF'],
350                                           'method' => 'GET',
351                               'accept-charset' => $GLOBALS['charset']),
352                         $js,
353                         HTML::table(HTML::tr(array('valign'=>'top'), $form)),
354                         HTML::input(array('type' => 'submit')),
355                         HTML::input(array('type' => 'reset')));
356     if ($start_debug)
357         $table->pushContent(HiddenInputs(array('start_debug' => $start_debug)));
358     return $table->printXml();
359 }
360
361 ####################################################################
362 #
363 # End of preamble, run the test suite ..
364 #
365 ####################################################################
366
367 ob_start();
368
369 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD']))
370     echo "<pre>\n";
371 elseif (!empty($HTTP_SERVER_VARS['argv']))
372     $argv = $HTTP_SERVER_VARS['argv'];
373 elseif (!ini_get("register_argc_argv"))
374     echo "Could not read cmd args (register_argc_argv=Off?)\n";
375 // purge the testbox
376     
377 $debug_level = 1; //was 9, _DEBUG_VERBOSE | _DEBUG_TRACE
378 if (defined('E_STRICT')) $debug_level = 5; // add PARSER flag on php5
379 $user_level  = 1; // BOGO (conflicts with RateIt)
380 // use argv (from cli) or tests (from browser) params to run only certain tests
381 // avoid pear: Console::Getopt
382 $alltests = array('InlineParserTest','HtmlParserTest',
383                   'PageListTest','ListPagesTest',
384                   'SetupWiki',
385                   'AllPagesTest','AllUsersTest','OrphanedPagesTest','WantedPagesTest',
386                   'DumpHtml');
387 // support db=file db=dba test=SetupWiki test=DumpHtml debug=num -dconstant=value
388 // or  db=file,dba test=SetupWiki,DumpHtml debug=num -dconstant=value
389 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
390     $argv = array();
391     foreach ($HTTP_GET_VARS as $key => $val) {
392         if (is_array($val))
393             foreach ($val as $k => $v) $argv[] = $key."=".$k;
394         elseif (strstr($val,",") and in_array($key, array("test","db")))
395             foreach (explode(",",$val) as $v) $argv[] = $key."=".$v;
396         else
397             $argv[] = $key."=".$val;
398     }
399 } elseif (!empty($argv) and preg_match("/test\.php$/", $argv[0])) {
400     array_shift($argv);
401 }    
402 if (!empty($argv)) {
403     $runtests = array();
404     $define = array();
405     $run_database_backends = array();
406     foreach ($argv as $arg) {
407         if (preg_match("/^test=(.+)$/",$arg,$m) and in_array($m[1], $alltests))
408             $runtests[] = $m[1];
409         elseif (preg_match("/^db=(.+)$/",$arg,$m) and in_array($m[1], $database_backends))
410             $run_database_backends[] = $m[1];
411         elseif (preg_match("/^debug=(\d+)$/",$arg,$m))
412             $debug_level = $m[1];
413         elseif (preg_match("/^level=(\d+)$/",$arg,$m))
414             $user_level = $m[1];
415         elseif (preg_match("/^\-d(\w+)=(.+)$/",$arg,$m)) {
416             $define[$m[1]] = $m[2];
417             if ($m[2] == 'true') $m[2] = true;
418             elseif ($m[2] == 'false') $m[2] = false;
419             if (!defined($m[1])) define($m[1], $m[2]);
420         } elseif (in_array($arg, $alltests))
421             $runtests[] = $arg;
422         elseif ($debug_level & 1)
423             echo "ignored arg: ", $arg, "\n";
424     }
425 }
426
427 if (empty($run_database_backends))
428     $run_database_backends = $database_backends;
429 if (empty($runtests))
430     $runtests = $alltests;
431 if ($debug_level & 1) {
432     //echo "\n";
433     echo "PHP_SAPI=",php_sapi_name(), "\n";
434     echo "PHP_OS=",PHP_OS, "\n";
435     echo "PHP_VERSION=",PHP_VERSION, "\n";
436     echo "test=", join(",",$runtests),"\n";
437     echo "db=", join(",",$run_database_backends),"\n";
438     echo "debug=", $debug_level,"\n";
439     echo "level=", $user_level,"\n";
440     if (!empty($define)) {
441         foreach ($define as $k => $v) printConstant($k);
442     }
443     if ($debug_level & 8) {
444         echo "pid=",getmypid(),"\n";
445     }
446     echo "\n";
447 }
448 flush();
449
450 if (!defined('DEBUG'))
451     define('DEBUG', $debug_level);
452 // override defaults:
453 if (!defined('RATING_STORAGE')) 
454    define('RATING_STORAGE', 'WIKIPAGE');
455 if (!defined('GROUP_METHOD'))
456     define('GROUP_METHOD', 'NONE');
457
458 if (DEBUG & 8)
459     printMemoryUsage("beforePEAR");
460
461 if (DEBUG & 8)
462     printMemoryUsage("beforePhpWiki");
463
464 define('PHPWIKI_NOMAIN', true);
465 # Other needed files
466 require_once $rootdir.'index.php';
467 require_once $rootdir.'lib/main.php';
468
469 // init filefinder for pear path fixup.
470 FindFile ('PHPUnit.php', 'missing_okay');
471 // PEAR library (requires version ??)
472 require_once 'PHPUnit.php';
473
474 ob_end_flush();
475
476 if ($debug_level & 1) {
477     //echo "\n";
478     echo "PHPWIKI_VERSION=",PHPWIKI_VERSION, strstr(PHPWIKI_VERSION,"pre") ? strftime(" / %Y%m%d") : "","\n";
479     if ($debug_level & 9) {
480         // which constants affect memory?
481         foreach (explode(",","USECACHE,WIKIDB_NOCACHE_MARKUP,ENABLE_USER_NEW,ENABLE_PAGEPERM") as $v) {
482             printConstant($v);
483         }
484     }
485     echo "\n";
486 }
487
488 global $ErrorManager;
489 $ErrorManager->setPostponedErrorMask(EM_FATAL_ERRORS|EM_WARNING_ERRORS|EM_NOTICE_ERRORS);
490 //FIXME: ignore cached requests (if-modified-since) from cli
491 class MockRequest extends WikiRequest {
492     function MockRequest(&$dbparams) {
493         $this->_dbi = WikiDB::open($dbparams);
494         $this->_user = new MockUser("a_user", $GLOBALS['user_level']);
495         $this->_group = new GroupNone();
496         $this->_args = array('pagename' => 'HomePage', 'action' => 'browse');
497         $this->Request();
498     }
499     function getGroup() {
500         if (is_object($this->_group))
501             return $this->_group;
502         else // FIXME: this is set to "/f:" somewhere.
503             return new GroupNone();
504     }
505 }
506
507 if (ENABLE_USER_NEW) {
508     class MockUser extends _WikiUser {
509         function MockUser($name, $level) {
510             $this->_userid = $name;
511             $this->_isSignedIn = $level > 1;
512             $this->_level = $level;
513         }
514         function isSignedIn() {
515             return $this->_isSignedIn;
516         }
517     }
518 } else {
519     class MockUser extends WikiUser {
520         function MockUser($name, $level) {
521             $this->_userid = $name;
522             $this->_isSignedIn = $level > 1;
523             $this->_level = $level;
524         }
525         function isSignedIn() {
526             return $this->_isSignedIn;
527         }
528     }
529 }
530
531 /*
532 if (ENABLE_USER_NEW)
533     $request->_user = WikiUser('AnonUser');
534 else {
535     $request->_user = new WikiUser($request, 'AnonUser');
536     $request->_prefs = $request->_user->getPreferences();
537 }
538 */
539 include_once("themes/" . THEME . "/themeinfo.php");
540 if (DEBUG & _DEBUG_TRACE)
541     printMemoryUsage("PhpWikiLoaded");
542
543 // provide a nice input form for all options
544 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
545     echo html_option_form();
546 }
547
548 // save and restore all args for each test.
549 class phpwiki_TestCase extends PHPUnit_TestCase {
550     function setUp() { 
551         global $request;
552         $this->_savedargs = $request->_args;
553         $request->_args = array();
554         if (DEBUG & 1) {
555             echo $this->_name,"\n";
556             flush();
557         }
558     }
559     function tearDown() {
560         global $request;
561         $request->_args = $this->_savedargs;
562         if (DEBUG & _DEBUG_TRACE)
563             printMemoryUsage();
564     }
565 }
566
567 # Test all db backends.
568 foreach ($run_database_backends as $dbtype) {
569     //    if (DEBUG & _DEBUG_TRACE)
570     //        printMemoryUsage("PHPUnitInitialized");
571
572     $DBParams['dbtype']               = $dbtype;
573     $DBParams['directory']            = $cur_dir . '/.testbox';
574     $DBParams['prefix']               = $database_prefix;
575     // from config.ini
576     //$DBParams['dsn']                  = $database_dsn;
577     //$DBParams['dba_handler']          = $database_dba_handler;
578
579     echo "Testing DB Backend \"$dbtype\" ...\n";
580     $request = new MockRequest($DBParams);
581     if ( ! ENABLE_USER_NEW ) {
582         $request->_user->_request =& $request;
583         $request->_user->_dbi =& $request->_dbi;
584     }
585     if (DEBUG & _DEBUG_TRACE)
586         printMemoryUsage("PhpWikiInitialized");
587
588     foreach ($runtests as $test) {
589         if (!@ob_get_level()) ob_start();
590         $suite  = new PHPUnit_TestSuite("phpwiki");
591         if (file_exists(dirname(__FILE__).'/lib/'.$test.'.php'))
592             require_once dirname(__FILE__).'/lib/'.$test.'.php';
593         else    
594             require_once dirname(__FILE__).'/lib/plugin/'.$test.'.php';
595         $suite->addTest( new PHPUnit_TestSuite($test) );
596
597         @set_time_limit(240); 
598         $result = PHPUnit::run($suite); 
599         echo "ran " . $result->runCount() . " tests, " . $result->failureCount() . " failures.\n";
600         ob_end_flush();
601         if ($result->failureCount() > 0) {
602             echo "More detail:\n";
603             echo $result->toString();
604         }
605     }
606
607     $request->chunkOutput();
608     $request->_dbi->close();
609     unset($request->_user);
610     unset($request->_dbi);
611     unset($request);
612     unset($suite);
613     unset($result);
614 }
615
616 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD']))
617     echo "</pre>\n";
618
619 // (c-file-style: "gnu")
620 // Local Variables:
621 // mode: php
622 // tab-width: 8
623 // c-basic-offset: 4
624 // c-hanging-comment-ender-p: nil
625 // indent-tabs-mode: nil
626 // End:   
627 ?>