]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/unit/test.php
IncludePageTest added, various minor enhancements
[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,2005 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 $LANG='en';
68
69 if (!empty($HTTP_SERVER_VARS) and $HTTP_SERVER_VARS["SERVER_NAME"] == 'phpwiki.sourceforge.net') {
70     ini_set('include_path', ini_get('include_path') . ":/usr/share/pear");
71     //define('ENABLE_PAGEPERM',false); // costs nothing
72     define('USECACHE',false); // really?
73     //define('WIKIDB_NOCACHE_MARKUP',1);
74 }
75
76 // available database backends to test:
77 $database_backends = array(
78                            'file',
79                            'dba',
80                            'SQL',   // default backend defined in the config.ini DSN
81                            'ADODB', // same backend as defined in the config.ini DSN
82                            // specific backends (need to be setup as db=test_phpwiki
83                            'PearDB_pgsql', 'PearDB_sqlite', 'PearDB_mysql',
84                            //'PearDB_oci8','PearDB_mssql', 
85                            'ADODB_postgres7', 'ADODB_sqlite', 'ADODB_mysql', 
86                            //'ADODB_oci8', 'ADODB_mssql', 
87                            );
88 if ((int)substr(phpversion(), 1) >= 5)
89     array_push($database_backends, 'PDO_pqsql', 'PDO_sqlite', 'PDO_mysql');
90                                    //'PDO_oci', 'PDO_odbc'
91
92 //TODO: convert cvs test                           
93 //TODO: read some database values from config.ini, just use the "test_" prefix
94 // "flatfile" testing occurs in "tests/unit/.testbox/"
95 // "dba" needs the DATABASE_DBA_HANDLER, also in the .textbox directory
96 //$database_dba_handler = (substr(PHP_OS,0,3) == 'WIN') ? "db3" : "gdbm";
97 // "SQL" and "ADODB" need delete permissions to the test db
98 //  You have to create that database beforehand with our schema
99 //$database_dsn = "mysql://wikiuser:@localhost/phpwiki";
100 $database_prefix = "test_";
101 // For "cvs" see the seperate tests/unit_test_backend_cvs.php (cvs is experimental)
102
103 // Quiet warnings in IniConfig.php
104 $HTTP_SERVER_VARS['REMOTE_ADDR'] = '127.0.0.1';
105 $HTTP_SERVER_VARS['HTTP_USER_AGENT'] = "PHPUnit";
106
107 function printMemoryUsage($msg = '') {
108     static $mem = 0;
109     static $initmem = 0;
110     if ($msg) echo $msg,"\n";
111     if ((defined('DEBUG') and (DEBUG & 8)) or !defined('DEBUG')) {
112         require_once("lib/stdlib.php");
113         echo "-- MEMORY USAGE: ";
114         $oldmem = $mem;
115         $mem = getMemoryUsage();
116         if (!$initmem) $initmem = $mem;
117         // old libc on sf.net server doesn't understand "%+4d"
118         echo sprintf("%8d\t[%s%4d]\t[+%4d]\n", $mem, $mem > $oldmem ? "+" : ($mem == $oldmem ? " " : ""), 
119                      $mem - $oldmem, $mem - $initmem);
120         // TODO: print time
121         flush();
122     }
123 }
124 /* // now in stdlib.php
125 function printSimpleTrace($bt) {
126     //print_r($bt);
127     echo "Traceback:\n";
128     foreach ($bt as $i => $elem) {
129         if (!array_key_exists('file', $elem)) {
130             continue;
131         }
132         print "  " . $elem['file'] . ':' . $elem['line'] . "\n";
133     }
134 }
135 */
136 // Show lots of detail when an assert() in the code fails
137 function assert_callback( $script, $line, $message ) {
138    echo "assert failed: script ", $script," line ", $line," :";
139    echo "$message";
140    if (function_exists('debug_backtrace')) { // >= 4.3.0
141        echo "Traceback:\n";
142        printSimpleTrace(debug_backtrace());
143    }
144    exit;
145 }
146 $foo = assert_options( ASSERT_CALLBACK, 'assert_callback');
147
148 //
149 // Get error reporting to call back, too
150 //
151 // set the error reporting level for this script
152 if (defined('E_STRICT') and (E_ALL & E_STRICT)) // strict php5?
153     error_reporting(E_ALL & ~E_STRICT);         // exclude E_STRICT
154 else
155     error_reporting(E_ALL); // php4
156
157 // This is too strict, fails on every notice and warning. 
158 /*
159 function myErrorHandler$errno, $errstr, $errfile, $errline) {
160    echo "$errfile: $errline: error# $errno: $errstr\n";
161    echo "Traceback:\n";
162    printSimpleTrace(debug_backtrace());
163 }
164 // The ErrorManager version
165 function _ErrorHandler_CB(&$error) {
166    echo "Traceback:\n";
167    printSimpleTrace(debug_backtrace());
168    if ($error->isFatal()) {
169         $error->errno = E_USER_WARNING;
170         return true; // ignore error
171    }
172    return true;
173 }
174 // set to the user defined error handler
175 // $old_error_handler = set_error_handler("myErrorHandler");
176 // This is already done via _DEBUG_TRACE
177 //$ErrorManager->pushErrorHandler(new WikiFunctionCb('_ErrorHandler_CB'));
178 */
179
180 function purge_dir($dir) {
181     static $finder;
182     if (!isset($finder)) {
183         $finder = new FileFinder;
184     }
185     $fileSet = new fileSet($dir);
186     assert(!empty($dir));
187     foreach ($fileSet->getFiles() as $f) {
188         unlink("$dir/$f");
189     }
190 }
191
192 function purge_testbox() {
193     global $DBParams;   
194     if (isset($GLOBALS['request'])) {
195         $dbi = $GLOBALS['request']->getDbh();
196     }
197     $dir = $DBParams['directory'];
198     switch ($DBParams['dbtype']) {
199     case 'file':
200         assert(!empty($dir));
201         foreach (array('latest_ver','links','page_data','ver_data') as $d) {
202             purge_dir("$dir/$d");
203         }
204         break;
205     case 'SQL':
206     case 'ADODB':
207     case 'PDO':
208         foreach ($dbi->_backend->_table_names as $table) {
209             $dbi->genericSqlQuery("DELETE FROM $table");
210         }
211         break;
212     case 'dba':
213         purge_dir($dir);
214         break;
215     }
216     if (isset($dbi)) {
217         $dbi->_cache->close();
218         $dbi->_backend->_latest_versions = array();
219     }
220 }
221
222 function printConstant($v) {
223     echo "$v=";
224     if (defined($v)) {
225         if (constant($v) or constant($v)===0 or constant($v)==='0') echo constant($v);
226         else echo "false";
227     } else echo "undefined";
228     echo "\n";
229 }
230 /**
231  * via the HTML sapi interface print a form to easily change the current cmdline settings.
232  */
233 function html_option_form() {
234     global $debug_level, $user_level, $start_debug;
235
236     $form = HTML();
237     $option = HTML::div(array('class' => 'option'), 
238                         HTML::span(array('style'=>'font-weight: bold','onDblClick'=>'flipAll(\'test[\')'), 'test: '),
239                         HTML::br());
240     foreach ($GLOBALS['alltests'] as $s) {
241         $input = array('type' => 'checkbox', 'name' => 'test['.$s.']', 'value' => '1');
242         if (in_array($s,$GLOBALS['runtests'])) $input['checked'] = 'checked';
243         $option->pushContent(HTML::input($input), $s, HTML::br());
244     }
245     $form->pushContent(HTML::td($option));
246
247     $option = HTML::div(array('class' => 'option'), 
248                         HTML::span(array('style'=>'font-weight: bold','onDblClick'=>'flipAll(\'db[\')'), 'db: '),
249                         HTML::br());
250     foreach ($GLOBALS['database_backends'] as $s) {
251         $input = array('type' => 'checkbox', 'name' => 'db['.$s.']', 'value' => '1');
252         if (in_array($s,$GLOBALS['run_database_backends'])) $input['checked'] = 'checked';
253         $option->pushContent(HTML::input($input), $s, HTML::br());
254     }
255     $form->pushContent(HTML::td($option));
256
257     $js = JavaScript(
258 "function flipAll(formName) {
259   var isFirstSet = -1;
260   formObj = document.forms[0];
261   for (var i=0; i < formObj.length; i++) {
262       fldObj = formObj.elements[i];
263       if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,formName.length) == formName)) { 
264          if (isFirstSet == -1)
265            isFirstSet = (fldObj.checked) ? true : false;
266          fldObj.checked = (isFirstSet) ? false : true;
267        }
268    }
269 }
270 function updateDebugEdit(formObj) {
271   val=0;
272   for (var i=0; i < formObj.length; i++) {
273       fldObj = formObj.elements[i];
274       if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,7) == '_debug[')) { 
275          if (fldObj.checked) val = val + parseInt(fldObj.value);
276        }
277    }
278    formObj.debug.value = val;
279 }
280 function updateLevelEdit(formObj) {
281   for (var i=0; i < formObj.length; i++) {
282       fldObj = formObj.elements[i];
283       if ((fldObj.type == 'radio') && (fldObj.name.substring(0,7) == '_level[')) {
284          if (fldObj.checked) {
285             formObj.level.value = fldObj.value;
286             return;
287          }
288       }
289    }
290 }");
291     $option = HTML::div(array('class' => 'option'),
292                         HTML::span(array('style'=>'font-weight: bold','onDblClick'=>'flipAll(\'_debug[\')'), 'debug: '),
293                         HTML::input(array('name'=>'debug','id'=>'debug','value'=>$debug_level,'size'=>5)),
294                         HTML::br());
295     foreach (array('VERBOSE'    => 1,
296                    'PAGELINKS'  => 2,
297                    'PARSER'     => 4,
298                    'TRACE'      => 8,
299                    'INFO'       => 16,
300                    'APD'        => 32,
301                    'LOGIN'      => 64,
302                    'SQL'        => 128,
303                    ) as $s => $v) {
304         $input = array('type' => 'checkbox', 'name' => '_debug[]', 'value' => $v, 
305                        'onClick' => 'updateDebugEdit(this.form)');
306         if ($debug_level & $v) $input['checked'] = 'checked';
307         $option->pushContent(HTML::input($input), "_DEBUG_".$s, HTML::br());
308     }
309     $form->pushContent(HTML::td($option));
310
311     $option = HTML::div(array('class' => 'option'), 
312                         HTML::span(array('style'=>'font-weight: bold'), "level: "),
313                         HTML::input(array('name'=>'level','id'=>'level','value'=>$user_level,'size'=>5)),
314                         HTML::br());
315     foreach (array('FORBIDDEN'  => -1,
316                    'ANON'       => 0,
317                    'BOGO'       => 1,
318                    'USER'       => 2,
319                    'ADMIN'      => 10,
320                    'UNOBTAINABLE'=> 100,
321                    ) as $s => $v) {
322         $input = array('type' => 'radio', 'name' => '_level[]', 'value' => $v,
323                        'onClick' => 'updateLevelEdit(this.form)');
324         if ($user_level & $v) $input['checked'] = 'checked';
325         $option->pushContent(HTML::input($input), "WIKIAUTH_".$s, HTML::br());
326     }
327     $form->pushContent(HTML::td($option));
328
329     unset($input);
330     $option = HTML::div(array('class' => 'option'), 'defines: ', HTML::br());
331     if (!empty($GLOBALS['define']))
332       foreach ($GLOBALS['define'] as $s) {
333         if (defined($s)) {
334             $input = array('type' => 'edit', 'name' => $s, 'value' => constant($s));
335             $option->pushContent(HTML::input($input), $s, HTML::br());
336         }
337     }
338     if (!empty($input))
339         $form->pushContent(HTML::td($option));
340     $table = HTML::form(array('action' => $_SERVER['PHP_SELF'],
341                                           'method' => 'GET',
342                               'accept-charset' => $GLOBALS['charset']),
343                         $js,
344                         HTML::table(HTML::tr(array('valign'=>'top'), $form)),
345                         HTML::input(array('type' => 'submit')),
346                         HTML::input(array('type' => 'reset')));
347     if ($start_debug)
348         $table->pushContent(HiddenInputs(array('start_debug' => $start_debug)));
349     return $table->printXml();
350 }
351
352 //####################################################################
353 //
354 // End of preamble, run the test suite ..
355 //
356 //####################################################################
357
358 ob_start();
359
360 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD']))
361     echo "<pre>\n";
362 elseif (!empty($HTTP_SERVER_VARS['argv']))
363     $argv = $HTTP_SERVER_VARS['argv'];
364 elseif (!ini_get("register_argc_argv"))
365     echo "Could not read cmd args (register_argc_argv=Off?)\n";
366 // purge the testbox
367     
368 $debug_level = 1; //was 9, _DEBUG_VERBOSE | _DEBUG_TRACE
369 //if (defined('E_STRICT')) $debug_level = 5; // add PARSER flag on php5
370 $user_level  = 1; // BOGO (conflicts with RateIt)
371 // use argv (from cli) or tests (from browser) params to run only certain tests
372 // avoid pear: Console::Getopt
373 $alltests = array('InlineParserTest','HtmlParserTest',
374                   'PageListTest','ListPagesTest',
375                   'SetupWiki',
376                   'AllPagesTest','AllUsersTest','OrphanedPagesTest','WantedPagesTest',
377                   'TextSearchTest','IncludePageTest',
378                   'DumpHtml');
379 // support db=file db=dba test=SetupWiki test=DumpHtml debug=num -dconstant=value
380 // or  db=file,dba test=SetupWiki,DumpHtml debug=num -dconstant=value
381 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
382     $argv = array();
383     foreach ($HTTP_GET_VARS as $key => $val) {
384         if (is_array($val))
385             foreach ($val as $k => $v) $argv[] = $key."=".$k;
386         elseif (strstr($val,",") and in_array($key, array("test","db")))
387             foreach (explode(",",$val) as $v) $argv[] = $key."=".$v;
388         else
389             $argv[] = $key."=".$val;
390     }
391 } elseif (!empty($argv) and preg_match("/test\.php$/", $argv[0])) {
392     array_shift($argv);
393 }    
394 if (!empty($argv)) {
395     $runtests = array();
396     $define = array();
397     $run_database_backends = array();
398     $m = array();
399     foreach ($argv as $arg) {
400         if (preg_match("/^test=(.+)$/",$arg,$m) and in_array($m[1], $alltests))
401             $runtests[] = $m[1];
402         elseif (preg_match("/^db=(.+)$/",$arg,$m) and in_array($m[1], $database_backends))
403             $run_database_backends[] = $m[1];
404         elseif (preg_match("/^debug=(\d+)$/",$arg,$m))
405             $debug_level = $m[1];
406         elseif (preg_match("/^level=(\d+)$/",$arg,$m))
407             $user_level = $m[1];
408         elseif (preg_match("/^\-d(\w+)=(.+)$/",$arg,$m)) {
409             $define[$m[1]] = $m[2];
410             if ($m[2] == 'true') $m[2] = true;
411             elseif ($m[2] == 'false') $m[2] = false;
412             if (!defined($m[1])) define($m[1], $m[2]);
413         } elseif (in_array($arg, $alltests))
414             $runtests[] = $arg;
415         elseif ($debug_level & 1)
416             echo "ignored arg: ", $arg, "\n";
417     }
418 }
419
420 if (empty($run_database_backends))
421     $run_database_backends = $database_backends;
422 if (empty($runtests))
423     $runtests = $alltests;
424 if ($debug_level & 1) {
425     //echo "\n";
426     echo "PHP_SAPI=",php_sapi_name(), "\n";
427     echo "PHP_OS=",PHP_OS, "\n";
428     echo "PHP_VERSION=",PHP_VERSION, "\n";
429     echo "test=", join(",",$runtests),"\n";
430     echo "db=", join(",",$run_database_backends),"\n";
431     echo "debug=", $debug_level,"\n";
432     echo "level=", $user_level,"\n";
433     if (!empty($define)) {
434         foreach ($define as $k => $v) printConstant($k);
435     }
436     if ($debug_level & 8) {
437         echo "pid=",getmypid(),"\n";
438     }
439     echo "\n";
440 }
441 flush();
442
443 if (!defined('DEBUG'))
444     define('DEBUG', $debug_level);
445 // override defaults:
446 if (!defined('RATING_STORAGE')) 
447    define('RATING_STORAGE', 'WIKIPAGE');
448 if (!defined('GROUP_METHOD'))
449     define('GROUP_METHOD', 'NONE');
450
451 if (DEBUG & 8)
452     printMemoryUsage("beforePEAR");
453
454 if (DEBUG & 8)
455     printMemoryUsage("beforePhpWiki");
456
457 define('PHPWIKI_NOMAIN', true);
458 // Other needed files
459 require_once $rootdir.'index.php';
460 require_once $rootdir.'lib/main.php';
461
462 // init filefinder for pear path fixup.
463 FindFile ('PHPUnit.php', 'missing_okay');
464 // PEAR library (requires version ??)
465 require_once 'PHPUnit.php';
466
467 ob_end_flush();
468
469 if ($debug_level & 1) {
470     //echo "\n";
471     echo "PHPWIKI_VERSION=",PHPWIKI_VERSION, strstr(PHPWIKI_VERSION,"pre") ? strftime(" / %Y%m%d") : "","\n";
472     if ($debug_level & 9) {
473         // which constants affect memory?
474         foreach (explode(",","USECACHE,WIKIDB_NOCACHE_MARKUP,ENABLE_USER_NEW,ENABLE_PAGEPERM") as $v) {
475             printConstant($v);
476         }
477     }
478     echo "\n";
479 }
480
481 global $ErrorManager;
482 $ErrorManager->setPostponedErrorMask(EM_FATAL_ERRORS|EM_WARNING_ERRORS|EM_NOTICE_ERRORS);
483 // FIXME: ignore cached requests (if-modified-since) from cli
484 class MockRequest extends WikiRequest {
485     function MockRequest($dbparams) {
486         $this->_dbi = WikiDB::open($dbparams);
487         $this->_user = new MockUser("a_user", $GLOBALS['user_level']);
488         $this->_group = new GroupNone();
489         $this->_args = array('pagename' => 'HomePage', 'action' => 'browse');
490         $this->Request();
491     }
492     function getGroup() {
493         if (is_object($this->_group))
494             return $this->_group;
495         else // FIXME: this is set to "/f:" somewhere.
496             return new GroupNone();
497     }
498 }
499
500 if (ENABLE_USER_NEW) {
501     class MockUser extends _WikiUser {
502         function MockUser($name, $level) {
503             $this->_userid = $name;
504             $this->_isSignedIn = $level > 1;
505             $this->_level = $level;
506         }
507         function isSignedIn() {
508             return $this->_isSignedIn;
509         }
510     }
511 } else {
512     class MockUser extends WikiUser {
513         function MockUser($name, $level) {
514             $this->_userid = $name;
515             $this->_isSignedIn = $level > 1;
516             $this->_level = $level;
517         }
518         function isSignedIn() {
519             return $this->_isSignedIn;
520         }
521     }
522 }
523
524 /*
525 if (ENABLE_USER_NEW)
526     $request->_user = WikiUser('AnonUser');
527 else {
528     $request->_user = new WikiUser($request, 'AnonUser');
529     $request->_prefs = $request->_user->getPreferences();
530 }
531 */
532 if (DEBUG & _DEBUG_TRACE)
533     printMemoryUsage("PhpWikiLoaded");
534
535 // provide a nice input form for all options
536 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
537     echo html_option_form();
538     flush();
539 }
540
541 // save and restore all args for each test.
542 class phpwiki_TestCase extends PHPUnit_TestCase {
543     function setUp() { 
544         global $request, $WikiTheme;
545         include_once("themes/" . THEME . "/themeinfo.php");
546         $this->_savedargs = $request->_args;
547         $request->_args = array();
548         if (DEBUG & 1) {
549             echo $this->_name,"\n";
550             flush();
551         }
552     }
553     function tearDown() {
554         global $request;
555         $request->_args = $this->_savedargs;
556         if (DEBUG & _DEBUG_TRACE)
557             printMemoryUsage();
558     }
559 }
560
561 // Test all db backends.
562 foreach ($run_database_backends as $dbtype) {
563     //    if (DEBUG & _DEBUG_TRACE)
564     //        printMemoryUsage("PHPUnitInitialized");
565     $DBParams['dbtype'] = $dbtype;
566     if (string_starts_with($dbtype, 'PearDB_')) {
567         $DBParams['dbtype'] = 'SQL';
568         preg_replace("/^([^:]+):/", substr($dbtype, 7).":", $DBParams['dsn']);
569     }
570     if (string_starts_with($dbtype, 'ADODB_')) {
571         $DBParams['dbtype'] = 'ADODB';
572         preg_replace("/^([^:]+):/", substr($dbtype, 6).":", $DBParams['dsn']);
573     }
574     if (string_starts_with($dbtype, 'PDO_')) {
575         $DBParams['dbtype'] = 'PDO';
576         preg_replace("/^([^:]+):/", substr($dbtype, 4).":", $DBParams['dsn']);
577     }
578     $DBParams['directory']            = $cur_dir . '/.testbox';
579     $DBParams['prefix']               = $database_prefix;
580     // from config.ini
581     //$DBParams['dba_handler']          = $database_dba_handler;
582
583     echo "Testing DB Backend \"$dbtype\" ...\n";
584     $request = new MockRequest($DBParams);
585     if ( ! ENABLE_USER_NEW ) {
586         $request->_user->_request =& $request;
587         $request->_user->_dbi =& $request->_dbi;
588     }
589     if (DEBUG & _DEBUG_TRACE)
590         printMemoryUsage("PhpWikiInitialized");
591
592     foreach ($runtests as $test) {
593         if (!@ob_get_level()) ob_start();
594         $suite  = new PHPUnit_TestSuite("phpwiki");
595         if (file_exists(dirname(__FILE__).'/lib/'.$test.'.php'))
596             require_once dirname(__FILE__).'/lib/'.$test.'.php';
597         else    
598             require_once dirname(__FILE__).'/lib/plugin/'.$test.'.php';
599         $suite->addTest( new PHPUnit_TestSuite($test) );
600
601         @set_time_limit(240); 
602         $result = PHPUnit::run($suite); 
603         echo "ran " . $result->runCount() . " tests, " . $result->failureCount() . " failures.\n";
604         ob_end_flush();
605         if ($result->failureCount() > 0) {
606             echo "More detail:\n";
607             echo $result->toString();
608         }
609     }
610
611     $request->chunkOutput();
612     $request->_dbi->close();
613     unset($request->_user);
614     unset($request->_dbi);
615     unset($request);
616     unset($suite);
617     unset($result);
618 }
619
620 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD']))
621     echo "</pre>\n";
622
623 // (c-file-style: "gnu")
624 // Local Variables:
625 // mode: php
626 // tab-width: 8
627 // c-basic-offset: 4
628 // c-hanging-comment-ender-p: nil
629 // indent-tabs-mode: nil
630 // End:   
631 ?>