add test for debug messages set into the server by client code
authorgggeek <giunta.gaetano@gmail.com>
Sat, 30 May 2015 09:28:06 +0000 (11:28 +0200)
committergggeek <giunta.gaetano@gmail.com>
Sat, 30 May 2015 09:28:06 +0000 (11:28 +0200)
demo/server/server.php
tests/3LocalhostTest.php
tests/4LocalhostMultiTest.php

index 180a108..f05557a 100644 (file)
@@ -37,6 +37,8 @@ class xmlrpcServerMethodsContainer
 {
     /**
      * Method used to test logging of php warnings generated by user functions.
+     * @param PhpXmlRpc\Request $req
+     * @return PhpXmlRpc\Response
      */
     public function phpWarningGenerator($req)
     {
@@ -46,12 +48,22 @@ class xmlrpcServerMethodsContainer
 
     /**
      * Method used to test catching of exceptions in the server.
+     * @param PhpXmlRpc\Request $req
+     * @throws Exception
      */
     public function exceptionGenerator($req)
     {
         throw new Exception("it's just a test", 1);
     }
 
+    /**
+     * @param string $msg
+     */
+    public function debugMessageGenerator($msg)
+    {
+        PhpXmlRpc\Server::xmlrpc_debugmsg($msg);
+    }
+
     /**
      * A PHP version of the state-number server. Send me an integer and i'll sell you a state.
      * Used to test wrapping of PHP methods into xmlrpc methods.
index a1f7dbf..220878e 100644 (file)
@@ -852,6 +852,15 @@ And turned it into nylon';
         }
     }
 
+    public function testServerComments()
+    {
+        $f = new xmlrpcmsg('tests.xmlrpcServerMethodsContainer.debugMessageGenerator', array(
+            new xmlrpcval('hello world', 'string'),
+        ));
+        $r = $this->send($f, 0, true);
+        $this->assertContains('hello world', $r->raw_data);
+    }
+
     public function testSendTwiceSameMsg()
     {
         $f = new xmlrpcmsg('examples.stringecho', array(
index 9243514..27eaafc 100644 (file)
@@ -19,7 +19,7 @@ class LocalhostMultiTest extends LocalhostTest
      */
     function _runtests()
     {
-        $unsafeMethods = array('testHttps', 'testCatchExceptions', 'testUtf8Method');
+        $unsafeMethods = array('testHttps', 'testCatchExceptions', 'testUtf8Method', 'testServerComments');
         foreach(get_class_methods('LocalhostTest') as $method)
         {
             if(strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))