瀏覽代碼

Merge r25258 to 1.12 release branch

git-svn-id: http://framework.zend.com/svn/framework/standard/branches/release-1.12@25259 44c647ce-9c0f-0410-b52a-842ac1e357ba
frosch 13 年之前
父節點
當前提交
d41a65ba79
共有 2 個文件被更改,包括 24 次插入8 次删除
  1. 6 6
      library/Zend/Gdata/App.php
  2. 18 2
      tests/Zend/Gdata/AppTest.php

+ 6 - 6
library/Zend/Gdata/App.php

@@ -724,14 +724,14 @@ class Zend_Gdata_App
      * @param  string $uri
      * @param  Zend_Http_Client $client The client used for communication
      * @param  string $className The class which is used as the return type
+     * @param  bool $useObjectMapping Enable/disable the use of XML to object mapping.
      * @throws Zend_Gdata_App_Exception
-     * @return string|Zend_Gdata_App_Feed Returns string only if the object
-     *                                    mapping has been disabled explicitly
-     *                                    by passing false to the
-     *                                    useObjectMapping() function.
+     * @return string|Zend_Gdata_App_Feed Returns string only if the fourth
+     *                                    parameter ($useObjectMapping) is set
+     *                                    to false.
      */
     public static function import($uri, $client = null,
-        $className='Zend_Gdata_App_Feed')
+        $className='Zend_Gdata_App_Feed', $useObjectMapping = true)
     {
         $app = new Zend_Gdata_App($client);
         $requestData = $app->prepareRequest('GET', $uri);
@@ -739,7 +739,7 @@ class Zend_Gdata_App
             $requestData['method'], $requestData['url']);
 
         $feedContent = $response->getBody();
-        if (!$this->_useObjectMapping) {
+        if (false === $useObjectMapping) {
             return $feedContent;
         }
         $feed = self::importString($feedContent, $className);

+ 18 - 2
tests/Zend/Gdata/AppTest.php

@@ -128,7 +128,7 @@ class Zend_Gdata_AppTest extends PHPUnit_Framework_TestCase
         $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n'));
 
         $this->service->setMajorProtocolVersion(1);
-        $this->service->setMinorProtocolVersion(NULL);
+        $this->service->setMinorProtocolVersion(null);
         $this->service->get('http://www.example.com');
 
         $headers = $this->adapter->popRequest()->headers;
@@ -162,7 +162,7 @@ class Zend_Gdata_AppTest extends PHPUnit_Framework_TestCase
         $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n'));
 
         $this->service->setMajorProtocolVersion(2);
-        $this->service->setMinorProtocolVersion(NULL);
+        $this->service->setMinorProtocolVersion(null);
         $this->service->get('http://www.example.com');
 
         $headers = $this->adapter->popRequest()->headers;
@@ -614,4 +614,20 @@ class Zend_Gdata_AppTest extends PHPUnit_Framework_TestCase
             $this->fail('Did not expect ErrorException');
         }
     }
+
+    /**
+     * @group ZF-10243
+     */
+    public function testStaticImportWithoutUsingObjectMapping()
+    {
+        $this->adapter->setResponse($this->httpEntrySample);
+        $feed = Zend_Gdata_App::import(
+            'http://www.example.com',
+            $this->client,
+            'Zend_Gdata_App_Feed',
+            false
+        );
+
+        $this->assertContains('<id>12345678901234567890</id>', $feed);
+    }
 }