Przeglądaj źródła

Added new public getConfig() method to Curl and Socket adapters to enable config tests to pass - fixes ZF-8076

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19086 44c647ce-9c0f-0410-b52a-842ac1e357ba
padraic 16 lat temu
rodzic
commit
77b8fca994

+ 11 - 0
library/Zend/Http/Client/Adapter/Curl.php

@@ -151,6 +151,17 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
 
         return $this;
     }
+    
+    /**
+     * Retrieve the array of all configuration options which
+     * are not simply passed immediately to CURL extension.
+     *
+     * @return array
+     */
+    public function getConfig()
+    {
+        return $this->_config;
+    }
 
     /**
      * Direct setter for cURL adapter related options.

+ 10 - 0
library/Zend/Http/Client/Adapter/Socket.php

@@ -111,6 +111,16 @@ class Zend_Http_Client_Adapter_Socket implements Zend_Http_Client_Adapter_Interf
             $this->config[strtolower($k)] = $v;
         }
     }
+    
+    /**
+     * Retrieve the array of all configuration options
+     *
+     * @return array
+     */
+    public function getConfig()
+    {
+        return $this->config;
+    }
 
     /**
      * Set the stream context for the TCP connection to the server

+ 1 - 0
tests/Zend/Http/Client/CommonHttpTests.php

@@ -916,4 +916,5 @@ abstract class Zend_Http_Client_CommonHttpTests extends PHPUnit_Framework_TestCa
             array(55)
         );
     }
+
 }

+ 2 - 2
tests/Zend/Http/Client/CurlTest.php

@@ -91,7 +91,7 @@ class Zend_Http_Client_CurlTest extends Zend_Http_Client_CommonHttpTests
 
         $this->_adapter->setConfig($config);
 
-        $hasConfig = $this->getObjectAttribute($this->_adapter, '_config');
+        $hasConfig = $this->_adapter->getConfig();
         foreach($config as $k => $v) {
             $this->assertEquals($v, $hasConfig[$k]);
         }
@@ -115,7 +115,7 @@ class Zend_Http_Client_CurlTest extends Zend_Http_Client_CommonHttpTests
 
         $this->_adapter->setConfig($config);
 
-        $hasConfig = $this->getObjectAttribute($this->_adapter, '_config');
+        $hasConfig = $this->_adapter->getConfig();
         $this->assertEquals($config->timeout, $hasConfig['timeout']);
         $this->assertEquals($config->nested->item, $hasConfig['nested']['item']);
     }

+ 3 - 3
tests/Zend/Http/Client/SocketTest.php

@@ -62,7 +62,7 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
 
     /**
      * Test that we can set a valid configuration array with some options
-     *
+     * @group ZHC001
      */
     public function testConfigSetAsArray()
     {
@@ -73,7 +73,7 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
 
         $this->_adapter->setConfig($config);
 
-        $hasConfig = $this->getObjectAttribute($this->_adapter, 'config');
+        $hasConfig = $this->_adapter->getConfig();
         foreach($config as $k => $v) {
             $this->assertEquals($v, $hasConfig[$k]);
         }
@@ -97,7 +97,7 @@ class Zend_Http_Client_SocketTest extends Zend_Http_Client_CommonHttpTests
 
         $this->_adapter->setConfig($config);
 
-        $hasConfig = $this->getObjectAttribute($this->_adapter, 'config');
+        $hasConfig = $this->_adapter->getConfig();
         $this->assertEquals($config->timeout, $hasConfig['timeout']);
         $this->assertEquals($config->nested->item, $hasConfig['nested']['item']);
     }