Browse Source

ZF-8032: Fixed a regression with the params allow in some of the methods to allow a string or an integer.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18494 44c647ce-9c0f-0410-b52a-842ac1e357ba
sidhighwind 16 years ago
parent
commit
8a7f47639d
2 changed files with 21 additions and 8 deletions
  1. 9 6
      library/Zend/Service/Twitter.php
  2. 12 2
      tests/Zend/Service/TwitterTest.php

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

@@ -207,6 +207,7 @@ class Zend_Service_Twitter extends Zend_Rest_Client
             include_once 'Zend/Service/Twitter/Exception.php';
             throw new Zend_Service_Twitter_Exception('Invalid method "' . $test . '"');
         }
+		
         return call_user_func_array(array($this , $test), $params);
     }
     /**
@@ -324,7 +325,7 @@ class Zend_Service_Twitter extends Zend_Rest_Client
         foreach ($params as $key => $value) {
             switch (strtolower($key)) {
                 case 'id':
-                    $path .= '/' . $this->_validInteger($value);
+                    $path .= '/' . $value;
                     break;
                 case 'page':
                     $_params['page'] = (int) $value;
@@ -457,10 +458,11 @@ class Zend_Service_Twitter extends Zend_Rest_Client
         $this->_init();
         $path = '/statuses/friends';
         $_params = array();
+		
         foreach ($params as $key => $value) {
             switch (strtolower($key)) {
                 case 'id':
-                    $path .= '/' . $this->_validInteger($value);
+                    $path .= '/' . $value;
                     break;
                 case 'page':
                     $_params['page'] = (int) $value;
@@ -470,6 +472,7 @@ class Zend_Service_Twitter extends Zend_Rest_Client
             }
         }
         $path .= '.xml';
+		
         $response = $this->_get($path, $_params);
         return new Zend_Rest_Client_Result($response->getBody());
     }
@@ -513,7 +516,7 @@ class Zend_Service_Twitter extends Zend_Rest_Client
     public function userShow ($id)
     {
         $this->_init();
-        $path = '/users/show/' . $this->_validInteger($id) . '.xml';
+        $path = '/users/show/' . $id . '.xml';
         $response = $this->_get($path);
         return new Zend_Rest_Client_Result($response->getBody());
     }
@@ -626,7 +629,7 @@ class Zend_Service_Twitter extends Zend_Rest_Client
     public function friendshipCreate ($id)
     {
         $this->_init();
-        $path = '/friendships/create/' . $this->_validInteger($id) . '.xml';
+        $path = '/friendships/create/' . $id . '.xml';
         $response = $this->_post($path);
         return new Zend_Rest_Client_Result($response->getBody());
     }
@@ -640,7 +643,7 @@ class Zend_Service_Twitter extends Zend_Rest_Client
     public function friendshipDestroy ($id)
     {
         $this->_init();
-        $path = '/friendships/destroy/' . $this->_validInteger($id) . '.xml';
+        $path = '/friendships/destroy/' . $id . '.xml';
         $response = $this->_post($path);
         return new Zend_Rest_Client_Result($response->getBody());
     }
@@ -655,7 +658,7 @@ class Zend_Service_Twitter extends Zend_Rest_Client
     {
         $this->_init();
         $path = '/friendships/exists.xml';
-        $data = array('user_a' => $this->getUsername() , 'user_b' => $this->_validInteger($id));
+        $data = array('user_a' => $this->getUsername() , 'user_b' => $id);
         $response = $this->_get($path, $data);
         return new Zend_Rest_Client_Result($response->getBody());
     }

+ 12 - 2
tests/Zend/Service/TwitterTest.php

@@ -362,6 +362,7 @@ class Zend_Service_TwitterTest extends PHPUnit_Framework_TestCase
     public function testFriendsTimelineStatusWithFriendSpecifiedReturnsResults()
     {
         /* @var $response Zend_Rest_Client_Result */
+		$this->insertTestTwitterData();
         $response = $this->twitter->status->friendsTimeline( array('id' => 'zftestuser1') );
         $this->assertTrue($response instanceof Zend_Rest_Client_Result);
         $httpClient    = $this->twitter->getLocalHttpClient();
@@ -606,18 +607,19 @@ class Zend_Service_TwitterTest extends PHPUnit_Framework_TestCase
 
     public function testUserFriendsSpecificUserReturnsResults()
     {
-        $response = $this->twitter->user->friends(array('id' =>'zftestuser1'));
+        $response = $this->twitter->user->friends(array('id' =>'ZendRssFeed'));
         $this->assertTrue($response instanceof Zend_Rest_Client_Result);
         $httpClient    = $this->twitter->getLocalHttpClient();
         $httpRequest   = $httpClient->getLastRequest();
         $httpResponse  = $httpClient->getLastResponse();
+
         $this->assertTrue($httpResponse->isSuccessful(), $httpResponse->getStatus() . ': ' . var_export($httpRequest, 1) . '\n' . $httpResponse->getHeadersAsString());
         $this->assertTrue(isset($response->status), $httpResponse->getStatus() . ': ' . var_export($httpRequest, 1) . '\n' . $httpResponse->getHeadersAsString());
 
         return $response;
     }
 
-    public function testUserShowReturnsResults()
+    public function testUserShowByIdReturnsResults()
     {
         $userInfo = $this->testUserFriendsSpecificUserReturnsResults();
         $userId = $userInfo->toValue($userInfo->user->id);
@@ -628,6 +630,14 @@ class Zend_Service_TwitterTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($userInfo->toValue($userInfo->user->name), $response->toValue($response->name));
         $this->assertEquals($userId, $response->toValue($response->id));
     }
+	
+	public function testUserShowByNameReturnsResults()
+    {
+        $response = $this->twitter->user->show('zftestuser1');
+        $this->assertTrue($response instanceof Zend_Rest_Client_Result);
+		
+        $this->assertEquals('zftestuser1', $response->toValue($response->screen_name));
+    }
 
     public function testStatusRepliesReturnsResults()
     {