From 94401ae0a89f07b54d88f756ac3ed876523b2b43 Mon Sep 17 00:00:00 2001 From: rurban Date: Fri, 21 Jan 2005 11:10:39 +0000 Subject: [PATCH] more tests git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4398 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- tests/xmlrpc/xmlrpc-client.php | 51 ++++++++++++++++++++++++++------- tests/xmlrpc/xmlrpc-servers.php | 33 +++++++++++++++++---- 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/tests/xmlrpc/xmlrpc-client.php b/tests/xmlrpc/xmlrpc-client.php index c821020d4..a829fae16 100644 --- a/tests/xmlrpc/xmlrpc-client.php +++ b/tests/xmlrpc/xmlrpc-client.php @@ -89,11 +89,11 @@ function match($a, $b) { } function pass($method) { - echo "pass $method()
"; + echo "pass $method()
"; } function fail($method, $sent, $received) { - echo "fail $method()
"; + echo "fail $method()
"; if ($sent) { echo "

sent

"; var_dump($sent); @@ -107,6 +107,7 @@ function fail($method, $sent, $received) { } } +// this needs to be fixed. function check_if_matches($method, $sent, $received) { if (match($sent, $received)) { pass($method); @@ -120,10 +121,13 @@ function foo($method_name, $args) { xmlrpc_encode_request($method_name, $args); } -function run_test($server, $debug, $output, $method, $args) { +function run_test($server, $debug, $output, $method, $args='', $expected='') { global $HTTP_GET_VARS; echo "<hr>"; - $params = array($args); + if (!is_array($args)) + $params = $args ? array($args) : array(); + else + $params = $args; if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support $server['uri'] .= "?start_debug=1"; $result = xu_rpc_http_concise(array('method' => $method, @@ -133,11 +137,12 @@ function run_test($server, $debug, $output, $method, $args) { 'port' => $server['port'], 'debug' => $debug, 'output' => $output)); - check_if_matches($method, $args, $result); + check_if_matches($method, $expected, $result); echo "</hr>"; flush(); } +// should return non-zero integer function run_no_param_test($server, $debug, $output, $method) { global $HTTP_GET_VARS; echo "<hr>"; @@ -164,12 +169,36 @@ function run_no_param_test($server, $debug, $output, $method) { // a method to run wiki tests against remote server. tests described at bottom. function run_easy_tests($server, $debug=0, $output = null) { - global $wiki_dmap; - - run_no_param_test($server, $debug, $output, "wiki.getRPCVersionSupported"); - // of the last day: - run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400, 1)); - /* ... */ + //global $wiki_dmap; + + run_test($server, $debug, $output, "wiki.getRPCVersionSupported", '', 1); + + // getRecentChanges of the last day: + // Note: may crash with dba + run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400)); + + run_test($server, $debug, $output, "wiki.getPage", "HomePage", "* What is a WikiWikiWeb? A description of this application. * Learn HowToUseWiki and learn about AddingPages. * Use the SandBox page to experiment with Wiki pages. * Please sign your name in RecentVisitors. * See RecentChanges for the latest page additions and changes. * Find out which pages are MostPopular. * Read the ReleaseNotes and RecentReleases. * Administer this wiki via PhpWikiAdministration. * See more PhpWikiDocumentation."); + run_test($server, $debug, $output, "wiki.getPageVersion", array("HomePage", 1)); + run_test($server, $debug, $output, "wiki.getPageHTML", "HomePage"); + run_test($server, $debug, $output, "wiki.getPageHTMLVersion", array("HomePage", 1)); + run_test($server, $debug, $output, "wiki.getAllPages"); + run_test($server, $debug, $output, "wiki.getPageInfo", "HomePage"); + run_test($server, $debug, $output, "wiki.getPageInfoVersion", array("HomePage", 1)); + run_test($server, $debug, $output, "wiki.listLinks", "HomePage"); + + run_test($server, $debug, $output, "wiki.putPage", + array("PutPage", "new PutPage content", "XxXx"), + array('code' => 200, 'version' => 1, 'message' => "Page PutPage version 1 created")); + run_test($server, $debug, $output, "wiki.putPage", + array("PutPage", "new PutPage content", "XxXx"), + array('code' => 400, 'version' => 1, 'message' => "Page PutPage unchanged")); + run_test($server, $debug, $output, "wiki.putPage", + array("PutPage", "new PutPage content", "disallowed"), + array('code' => 401, 'version' => 0, 'message' => "no permission for disallowed")); + + run_test($server, $debug, $output, "wiki.rssPleaseNotify", "HomePage", 0); + run_test($server, $debug, $output, "wiki.mailPasswordToUser", ADMIN_USER); + } function run_stress_tests($server, $debug=0, $output=null) { diff --git a/tests/xmlrpc/xmlrpc-servers.php b/tests/xmlrpc/xmlrpc-servers.php index c6b1463cf..e3f8cf611 100644 --- a/tests/xmlrpc/xmlrpc-servers.php +++ b/tests/xmlrpc/xmlrpc-servers.php @@ -27,25 +27,46 @@ function get_wiki_servers($include_user=true) { $list = array ( array('title' => " local ", - 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/../../RPC2.php", + 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/../../index.php", 'args' => null, 'host' => $GLOBALS['SERVER_NAME'], - 'uri' => dirname($GLOBALS['PHP_SELF'])."/../../RPC2.php", + 'uri' => dirname($GLOBALS['PHP_SELF'])."/../../index.php", 'port' => $GLOBALS['SERVER_PORT'], "default" => true ), + array('title' => "local dba-test", + 'info_link' => "http://".$GLOBALS['SERVER_NAME']."/wiki/dba", + 'args' => null, + 'host' => $GLOBALS['SERVER_NAME'], + 'uri' => "/wiki/dba", + 'port' => 80 + ), + array('title' => "local pear-test", + 'info_link' => "http://".$GLOBALS['SERVER_NAME']."/wiki/pear", + 'args' => null, + 'host' => $GLOBALS['SERVER_NAME'], + 'uri' => "/wiki/pear", + 'port' => 80 + ), + array('title' => "local adodb-test", + 'info_link' => "http://".$GLOBALS['SERVER_NAME']."/wiki/adodb", + 'args' => null, + 'host' => $GLOBALS['SERVER_NAME'], + 'uri' => "/wiki/adodb", + 'port' => 80 + ), array('title' => "PhpWiki", - 'info_link' => "http://phpwiki.sourceforge.net/phpwiki/RPC2.php", + 'info_link' => "http://phpwiki.sourceforge.net/phpwiki/", 'args' => null, 'host' => "phpwiki.sourceforge.net", - 'uri' => "/phpwiki/RPC2.PHP", + 'uri' => "/phpwiki/", 'port' => 80 ), array('title' => "PhpWikiDemo", - 'info_link' => "http://phpwiki.sourceforge.net/demo/RPC2.php", + 'info_link' => "http://phpwiki.sourceforge.net/demo/", 'args' => null, 'host' => "phpwiki.sourceforge.net", - 'uri' => "/demo/RPC2.php", + 'uri' => "/demo/", 'port' => 80 ), ); -- 2.45.0