فهرست منبع

[ZF-10524] Zend_Soap_Client unsets options with a value of 0

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23266 44c647ce-9c0f-0410-b52a-842ac1e357ba
jan 15 سال پیش
والد
کامیت
8a3effee1f
2فایلهای تغییر یافته به همراه58 افزوده شده و 8 حذف شده
  1. 16 8
      library/Zend/Soap/Client.php
  2. 42 0
      tests/Zend/Soap/ClientTest.php

+ 16 - 8
library/Zend/Soap/Client.php

@@ -321,7 +321,7 @@ class Zend_Soap_Client
              * ugly hack as I don't know if checking for '=== null'
              * breaks some other option
              */
-            if ($key == 'user_agent') {
+            if (in_array($key, array('user_agent', 'cache_wsdl', 'compression'))) {
                 if ($value === null) {
                     unset($options[$key]);
                 }
@@ -767,15 +767,17 @@ class Zend_Soap_Client
     /**
      * Set compression options
      *
-     * @param  int $compressionOptions
+     * @param  int|null $compressionOptions
      * @return Zend_Soap_Client
      */
     public function setCompressionOptions($compressionOptions)
     {
-        $this->_compression = $compressionOptions;
-
+        if ($compressionOptions === null) {
+            $this->_compression = null;
+        } else {
+            $this->_compression = (int)$compressionOptions;
+        }
         $this->_soapClient = null;
-
         return $this;
     }
 
@@ -857,17 +859,23 @@ class Zend_Soap_Client
     /**
      * Set the SOAP Wsdl Caching Options
      *
-     * @param string|int|boolean $caching
+     * @param string|int|boolean|null $caching
      * @return Zend_Soap_Client
      */
-    public function setWsdlCache($options)
+    public function setWsdlCache($caching)
     {
-        $this->_cache_wsdl = $options;
+        if ($caching === null) {
+            $this->_cache_wsdl = null;
+        } else {
+            $this->_cache_wsdl = (int)$caching;
+        }
         return $this;
     }
 
     /**
      * Get current SOAP Wsdl Caching option
+     *
+     * @return int
      */
     public function getWsdlCache()
     {

+ 42 - 0
tests/Zend/Soap/ClientTest.php

@@ -223,6 +223,48 @@ class Zend_Soap_ClientTest extends PHPUnit_Framework_TestCase
         $this->assertArrayNotHasKey('user_agent', $options);
     }
 
+    /**
+     * @group ZF-10524
+     */
+    public function testAllowNumericZeroAsValueForCacheWsdlOption()
+    {
+        $client = new Zend_Soap_Client();
+        $this->assertNull($client->getWsdlCache());
+        $options = $client->getOptions();
+        $this->assertArrayNotHasKey('cache_wsdl', $options);
+
+        $client->setWsdlCache(WSDL_CACHE_NONE);
+        $this->assertSame(WSDL_CACHE_NONE, $client->getWsdlCache());
+        $options = $client->getOptions();
+        $this->assertSame(WSDL_CACHE_NONE, $options['cache_wsdl']);
+
+        $client->setWsdlCache(null);
+        $this->assertNull($client->getWsdlCache());
+        $options = $client->getOptions();
+        $this->assertArrayNotHasKey('cache_wsdl', $options);
+    }
+
+    /**
+     * @group ZF-10524
+     */
+    public function testAllowNumericZeroAsValueForCompressionOptions()
+    {
+        $client = new Zend_Soap_Client();
+        $this->assertNull($client->getCompressionOptions());
+        $options = $client->getOptions();
+        $this->assertArrayNotHasKey('compression', $options);
+
+        $client->setCompressionOptions(SOAP_COMPRESSION_GZIP);
+        $this->assertSame(SOAP_COMPRESSION_GZIP, $client->getCompressionOptions());
+        $options = $client->getOptions();
+        $this->assertSame(SOAP_COMPRESSION_GZIP, $options['compression']);
+
+        $client->setCompressionOptions(null);
+        $this->assertNull($client->getCompressionOptions());
+        $options = $client->getOptions();
+        $this->assertArrayNotHasKey('compression', $options);
+    }
+
     public function testGetFunctions()
     {
         $server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl');