Jelajahi Sumber

[ZF-11023] Fix object config in the contructor of the service twitter.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23698 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon 15 tahun lalu
induk
melakukan
2a7fa4e89d

+ 6 - 2
library/Zend/Service/Twitter.php

@@ -131,11 +131,15 @@ class Zend_Service_Twitter extends Zend_Rest_Client
     public function __construct($options = null, Zend_Oauth_Consumer $consumer = null)
     {
         $this->setUri('http://api.twitter.com');
-        if (!is_array($options)) $options = array();
-        $options['siteUrl'] = self::OAUTH_BASE_URI;
         if ($options instanceof Zend_Config) {
             $options = $options->toArray();
         }
+
+        if (!is_array($options)) {
+            $options = array();
+        }
+        $options['siteUrl'] = self::OAUTH_BASE_URI;
+
         $this->_options = $options;
         if (isset($options['username'])) {
             $this->setUsername($options['username']);

+ 10 - 0
tests/Zend/Service/Twitter/TwitterTest.php

@@ -647,6 +647,16 @@ class Zend_Service_Twitter_TwitterTest extends PHPUnit_Framework_TestCase
         $timeline = $twitter->statusUserTimeline($params);
     }
 
+    /**
+     * @group ZF-11023
+     */
+    public function testConstructorPassedObjectZendConfig()
+    {
+        require_once 'Zend/Config.php';
+        $config = new Zend_Config(array('username' => 'zf'));
+        $twitter = new Zend_Service_Twitter($config);
+        $this->assertEquals('zf', $twitter->getUsername());
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Service_TwitterTest2::main') {