Jelajahi Sumber

fixes ZF-9317 and ZF-9318
about not sending data with Zend_Rest_Client::restDelete
about final methods in Zend_Rest_Client

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24273 44c647ce-9c0f-0410-b52a-842ac1e357ba

mcleod@spaceweb.nl 14 tahun lalu
induk
melakukan
bf565bcf42
2 mengubah file dengan 10 tambahan dan 7 penghapusan
  1. 6 6
      library/Zend/Rest/Client.php
  2. 4 1
      tests/Zend/Rest/ClientTest.php

+ 6 - 6
library/Zend/Rest/Client.php

@@ -98,7 +98,7 @@ class Zend_Rest_Client extends Zend_Service_Abstract
      * @throws Zend_Rest_Client_Exception
      * @return void
      */
-    final private function _prepareRest($path)
+    private function _prepareRest($path)
     {
         // Get the URI object and configure it
         if (!$this->_uri instanceof Zend_Uri_Http) {
@@ -129,7 +129,7 @@ class Zend_Rest_Client extends Zend_Service_Abstract
      * @throws Zend_Http_Client_Exception
      * @return Zend_Http_Response
      */
-    final public function restGet($path, array $query = null)
+    public function restGet($path, array $query = null)
     {
         $this->_prepareRest($path);
         $client = self::getHttpClient();
@@ -167,7 +167,7 @@ class Zend_Rest_Client extends Zend_Service_Abstract
      * @throws Zend_Http_Client_Exception
      * @return Zend_Http_Response
      */
-    final public function restPost($path, $data = null)
+    public function restPost($path, $data = null)
     {
         $this->_prepareRest($path);
         return $this->_performPost('POST', $data);
@@ -181,7 +181,7 @@ class Zend_Rest_Client extends Zend_Service_Abstract
      * @throws Zend_Http_Client_Exception
      * @return Zend_Http_Response
      */
-    final public function restPut($path, $data = null)
+    public function restPut($path, $data = null)
     {
         $this->_prepareRest($path);
         return $this->_performPost('PUT', $data);
@@ -194,10 +194,10 @@ class Zend_Rest_Client extends Zend_Service_Abstract
      * @throws Zend_Http_Client_Exception
      * @return Zend_Http_Response
      */
-    final public function restDelete($path)
+    public function restDelete($path, $data = null)
     {
         $this->_prepareRest($path);
-        return self::getHttpClient()->request('DELETE');
+        return $this->_performPost('DELETE', $data);
     }
 
     /**

+ 4 - 1
tests/Zend/Rest/ClientTest.php

@@ -220,10 +220,13 @@ class Zend_Rest_ClientTest extends PHPUnit_Framework_TestCase
         $this->adapter->setResponse($response);
 
         $reqXml   = file_get_contents($this->path . 'returnInt.xml');
-        $response = $this->rest->restDelete('/rest/');
+        $response = $this->rest->restDelete('/rest/', $reqXml);
         $this->assertTrue($response instanceof Zend_Http_Response);
         $body = $response->getBody();
         $this->assertContains($expXml, $response->getBody());
+        
+        $request = Zend_Rest_Client::getHttpClient()->getLastRequest();
+        $this->assertContains($reqXml, $request, $request);
     }
 
     public function testCallWithHttpMethod()