From 3cb8e96d8cab32cb117518cc305b953b358a2651 Mon Sep 17 00:00:00 2001
From: gggeek <giunta.gaetano@gmail.com>
Date: Sat, 30 May 2015 11:28:06 +0200
Subject: [PATCH] add test for debug messages set into the server by client
 code

---
 demo/server/server.php        | 12 ++++++++++++
 tests/3LocalhostTest.php      |  9 +++++++++
 tests/4LocalhostMultiTest.php |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/demo/server/server.php b/demo/server/server.php
index 180a1088..f05557a7 100644
--- a/demo/server/server.php
+++ b/demo/server/server.php
@@ -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.
diff --git a/tests/3LocalhostTest.php b/tests/3LocalhostTest.php
index a1f7dbf5..220878ea 100644
--- a/tests/3LocalhostTest.php
+++ b/tests/3LocalhostTest.php
@@ -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(
diff --git a/tests/4LocalhostMultiTest.php b/tests/4LocalhostMultiTest.php
index 9243514b..27eaafc3 100644
--- a/tests/4LocalhostMultiTest.php
+++ b/tests/4LocalhostMultiTest.php
@@ -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))
-- 
2.47.0