Przeglądaj źródła

ZF-8074: Fixing problem when calling a webservice method with a Zend_XmlRpc_Value_DateTime object as parameter

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19564 44c647ce-9c0f-0410-b52a-842ac1e357ba
lars 16 lat temu
rodzic
commit
771abf9224
2 zmienionych plików z 32 dodań i 7 usunięć
  1. 7 0
      library/Zend/XmlRpc/Client.php
  2. 25 7
      tests/Zend/XmlRpc/ClientTest.php

+ 7 - 0
library/Zend/XmlRpc/Client.php

@@ -331,16 +331,23 @@ class Zend_XmlRpc_Client
                 );
                 $params = (array)$params;
                 foreach ($params as $key => $param) {
+
+                    if ($param instanceof Zend_XmlRpc_Value) {
+                        continue;
+                    }
+
                     $type = Zend_XmlRpc_Value::AUTO_DETECT_TYPE;
                     foreach ($signatures as $signature) {
                         if (!is_array($signature)) {
                             continue;
                         }
+
                         if (isset($signature['parameters'][$key])) {
                             $type = $signature['parameters'][$key];
                             $type = in_array($type, $validTypes) ? $type : Zend_XmlRpc_Value::AUTO_DETECT_TYPE;
                         }
                     }
+
                     $params[$key] = Zend_XmlRpc_Value::getXmlRpcValue($param, $type);
                 }
             }

+ 25 - 7
tests/Zend/XmlRpc/ClientTest.php

@@ -222,7 +222,7 @@ class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * @see ZF-1797
+     * @group ZF-1797
      */
     public function testSuccesfulRpcMethodCallWithXmlRpcValueParameters()
     {
@@ -249,7 +249,7 @@ class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * @see ZF-2978
+     * @group ZF-2978
      */
     public function testSkippingSystemCallDisabledByDefault()
     {
@@ -257,15 +257,16 @@ class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * @see ZF-6993
+     * @group ZF-6993
      */
     public function testWhenPassingAStringAndAnIntegerIsExpectedParamIsConverted()
     {
         $this->mockIntrospector();
-        $this->mockedIntrospector->expects($this->exactly(2))
-                           ->method('getMethodSignature')
-                           ->with('test.method')
-                           ->will($this->returnValue(array(array('parameters' => array('int')))));
+        $this->mockedIntrospector
+             ->expects($this->exactly(2))
+             ->method('getMethodSignature')
+             ->with('test.method')
+             ->will($this->returnValue(array(array('parameters' => array('int')))));
 
         $expect = 'test.method response';
         $this->setServerResponseTo($expect);
@@ -280,6 +281,23 @@ class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase
         $this->assertSame(1, $params[0]->getValue());
     }
 
+    /**
+     * @group ZF-8074
+     */
+    public function testXmlRpcObjectsAreNotConverted()
+    {
+        $this->mockIntrospector();
+        $this->mockedIntrospector
+             ->expects($this->exactly(1))
+             ->method('getMethodSignature')
+             ->with('date.method')
+             ->will($this->returnValue(array(array('parameters' => array('dateTime.iso8601', 'string')))));
+
+        $expects = 'date.method response';
+        $this->setServerResponseTo($expects);
+        $this->assertSame($expects, $this->xmlrpcClient->call('date.method', array(Zend_XmlRpc_Value::getXmlRpcValue(time(), Zend_XmlRpc_Value::XMLRPC_TYPE_DATETIME), 'foo')));
+    }
+
     public function testAllowsSkippingSystemCallForArrayStructLookup()
     {
         $this->xmlrpcClient->setSkipSystemLookup(true);