From 6b7202618ff9d635c19ca3202becb016705b520c Mon Sep 17 00:00:00 2001 From: rurban Date: Wed, 3 Nov 2004 16:47:10 +0000 Subject: [PATCH] some unit tests fixes and updates git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4080 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- tests/AAD_FindText.inputs | 6 +++--- tests/CompatInfo.php | 9 ++++++--- tests/unit/lib/DumpHtml.php | 4 ++-- tests/unit/lib/plugin/AllPagesTest.php | 16 ++++++++++++---- tests/unit/test.php | 16 ++++++++++++---- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/tests/AAD_FindText.inputs b/tests/AAD_FindText.inputs index daed8893b..ee18ec22d 100644 --- a/tests/AAD_FindText.inputs +++ b/tests/AAD_FindText.inputs @@ -1,16 +1,16 @@ # Test the page WabiSabi for the text # string "imperfect, impermanent, and incomplete" -# $Id: AAD_FindText.inputs,v 1.2 2002-01-29 22:15:31 wainstead Exp $ +# $Id: AAD_FindText.inputs,v 1.3 2004-11-03 16:47:09 rurban Exp $ # get the starting page type: starting_page -start_url: index.php/WabiSabi +start_url: index.php?WabiSabi assert_text: imperfect, impermanent, and incomplete go # check the page for certain text type: follow_link -follow_link: "History" +follow_link: "PageHistory" assert_url: WabiSabi go diff --git a/tests/CompatInfo.php b/tests/CompatInfo.php index 11e1f60d9..e54fbc46f 100755 --- a/tests/CompatInfo.php +++ b/tests/CompatInfo.php @@ -2,7 +2,7 @@ /* Get the Compatibility info for phpwiki http://pear.php.net/package/PHP_CompatInfo - $Id: CompatInfo.php,v 1.2 2004-08-24 00:27:29 rurban Exp $ + $Id: CompatInfo.php,v 1.3 2004-11-03 16:47:09 rurban Exp $ */ /* * Copyright (C) 2004 Reini Urban @@ -80,9 +80,9 @@ out_row($cols,1); foreach ($r as $key => $info) { if ($key == 'extensions') - out_row(array("$key", '', join(',',$info), '')); + out_row(array("$key", '', join(', ',$info), '')); elseif ($key == 'constants') - out_row(array("$key", '', '', join(',',$info))); + out_row(array("$key", '', '', join(', ',$info))); elseif ($key == 'version') out_row(array("$key", $info, '', '')); elseif ($key == 'ignored_files') @@ -154,6 +154,9 @@ if ($debug) { } // $Log: not supported by cvs2svn $ +// Revision 1.2 2004/08/24 00:27:29 rurban +// Turn recursion on +// // Revision 1.1 2004/08/24 00:21:57 rurban // Print the PHP compatibility info for phpwiki. // per file and per project, diff --git a/tests/unit/lib/DumpHtml.php b/tests/unit/lib/DumpHtml.php index 3dc870326..f1895267d 100644 --- a/tests/unit/lib/DumpHtml.php +++ b/tests/unit/lib/DumpHtml.php @@ -11,7 +11,7 @@ class DumpHtml extends phpwiki_TestCase { function _dumpPage($pagename) { global $request, $cur_dir; - $request->setArg('directory','.dumphtml'); + $request->setArg('directory',$cur_dir.'/.dumphtml'); $request->setArg('pages', $pagename); $request->setArg('action', 'dumphtml'); unlink($cur_dir."/.dumphtml/$pagename.html"); @@ -34,7 +34,7 @@ class DumpHtml extends phpwiki_TestCase { function test99DumpHtml() { global $request, $cur_dir; - $request->setArg('directory','.dumphtml'); + $request->setArg('directory',$cur_dir.'/.dumphtml'); purge_dir($cur_dir."/.dumphtml"); purge_dir($cur_dir."/.dumphtml/images"); $request->setArg('pages',''); diff --git a/tests/unit/lib/plugin/AllPagesTest.php b/tests/unit/lib/plugin/AllPagesTest.php index d88b65b05..ddc340752 100644 --- a/tests/unit/lib/plugin/AllPagesTest.php +++ b/tests/unit/lib/plugin/AllPagesTest.php @@ -15,16 +15,24 @@ class AllPagesTest extends phpwiki_TestCase { $lp = new WikiPlugin_AllPages(); $this->assertEquals("AllPages", $lp->getName()); $args = ""; + $this->assertType('object', $request->_dbi, 'isa WikiDB'); +/* +*/ + $result = $lp->run($request->_dbi, $args, $request, "AllPages"); + $this->assertType('object', $result, 'isa PageList'); + $this->assertType('object', $request->_dbi, 'isa WikiDB'); if (!isa($request->_dbi, "WikiDB")) { // very very strange bug - $request->_dbi = WikiDB::open($GLOBALS['db_params']); + $request->_dbi = WikiDB::open($GLOBALS['DBParams']); if (!isa($request->_dbi, "WikiDB")) { trigger_error("strange php bug\n",E_USER_WARNING); return; } - } - $result = $lp->run($request->getDbh(), $args, $request, "AllPages"); - $this->assertType('object', $result, 'isa PageList'); + } + $xml = $result->asXml(); + $this->assertType('object', $result, 'isa XmlContent'); + //$xml->asString(); + //$this->assertType('object', $result, 'isa XmlContent'); } } diff --git a/tests/unit/test.php b/tests/unit/test.php index 6627f5d15..9f184d644 100644 --- a/tests/unit/test.php +++ b/tests/unit/test.php @@ -240,7 +240,7 @@ function printConstant($v) { # #################################################################### -# lib/config.php might do a cwd() +ob_start(); if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) echo "
\n";
@@ -254,8 +254,11 @@ $debug_level = 1; //was 9, _DEBUG_VERBOSE | _DEBUG_TRACE
 $user_level  = 1; // BOGO (conflicts with RateIt)
 // use argv (from cli) or tests (from browser) params to run only certain tests
 // avoid pear: Console::Getopt
-$alltests = array('InlineParserTest','HtmlParserTest','PageListTest','ListPagesTest',
-                  'SetupWiki','DumpHtml','AllPagesTest','AllUsersTest','OrphanedPagesTest');
+$alltests = array('InlineParserTest','HtmlParserTest',
+                  'PageListTest','ListPagesTest',
+                  'SetupWiki',
+                  'AllPagesTest','AllUsersTest','OrphanedPagesTest',
+                  'DumpHtml');
 if (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
     $argv = array();
     foreach ($HTTP_GET_VARS as $key => $val) {
@@ -330,6 +333,7 @@ define('PHPWIKI_NOMAIN', true);
 # Other needed files
 require_once $rootdir.'index.php';
 require_once $rootdir.'lib/main.php';
+ob_end_flush();
 
 if ($debug_level & 1) {
     echo "\n";
@@ -440,6 +444,7 @@ foreach ($database_backends as $dbtype) {
         printMemoryUsage("PhpWikiInitialized");
 
     foreach ($alltests as $test) {
+    	if (!@ob_get_level()) ob_start();
         $suite  = new PHPUnit_TestSuite("phpwiki");
         if (file_exists(dirname(__FILE__).'/lib/'.$test.'.php'))
             require_once dirname(__FILE__).'/lib/'.$test.'.php';
@@ -450,7 +455,7 @@ foreach ($database_backends as $dbtype) {
         @set_time_limit(240); 
         $result = PHPUnit::run($suite); 
         echo "ran " . $result->runCount() . " tests, " . $result->failureCount() . " failures.\n";
-        flush();
+        ob_end_flush();
         if ($result->failureCount() > 0) {
             echo "More detail:\n";
             echo $result->toString();
@@ -458,6 +463,9 @@ foreach ($database_backends as $dbtype) {
     }
 
     $request->chunkOutput();
+    $request->_dbi->close();
+    unset($request->_user);
+    unset($request->_dbi);
     unset($request);
     unset($suite);
     unset($result);
-- 
2.45.0