Sfoglia il codice sorgente

Fix for Zend_Service_ShortUrl unit tests failures.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23190 44c647ce-9c0f-0410-b52a-842ac1e357ba
alexander 15 anni fa
parent
commit
1e4c2f7174

+ 2 - 0
tests/Zend/Service/ShortUrl/IsGdTest.php

@@ -47,6 +47,8 @@ class Zend_Service_ShortUrl_IsGdTest extends PHPUnit_Framework_TestCase
      */
     public function setUp ()
     {
+        Zend_Service_Abstract::setHttpClient(new Zend_Http_Client());
+
         $this->_s = new Zend_Service_ShortUrl_IsGd();
         $this->_s->getHttpClient()->resetParameters(true);
     }

+ 11 - 9
tests/Zend/Service/ShortUrl/JdemCzTest.php

@@ -39,7 +39,7 @@ class Zend_Service_ShortUrl_JdemCzTest extends PHPUnit_Framework_TestCase
      * @var Zend_Service_JdemCz
      */
     protected $_s;
-    
+
     /**
      * Creates a new Zend_Service_JdemCz object for each test method
      *
@@ -47,6 +47,8 @@ class Zend_Service_ShortUrl_JdemCzTest extends PHPUnit_Framework_TestCase
      */
     public function setUp ()
     {
+        Zend_Service_Abstract::setHttpClient(new Zend_Http_Client());
+
         $this->_s = new Zend_Service_ShortUrl_JdemCz();
     }
 
@@ -55,49 +57,49 @@ class Zend_Service_ShortUrl_JdemCzTest extends PHPUnit_Framework_TestCase
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->shorten('');
     }
-    
+
     public function testShortenIncorrectUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->shorten('wrongAdress.cccc');
     }
-    
+
     public function testShorten()
     {
         $urls = array(
             'http://framework.zend.com/'           => 'http://jdem.cz/ab2l1',
             'http://framework.zend.com/manual/en/' => 'http://jdem.cz/ab3z7'
         );
-        
+
         foreach ($urls as $url => $shortenedUrl) {
             $this->assertEquals($shortenedUrl, $this->_s->shorten($url));
         }
     }
-    
+
     public function testUnshorten()
     {
         $urls = array(
             'http://framework.zend.com/'           => 'http://jdem.cz/ab2l1',
             'http://framework.zend.com/manual/en/' => 'http://jdem.cz/ab3z7'
         );
-        
+
         foreach ($urls as $url => $shortenedUrl) {
             $this->assertEquals($url, $this->_s->unshorten($shortenedUrl));
         }
     }
-    
+
     public function testUnshortenEmptyUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->unshorten('');
     }
-    
+
     public function testUnshortenIncorrectUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->unshorten('wrongAdress.cccc');
     }
-    
+
     public function testUnshortenWrongUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');

+ 11 - 9
tests/Zend/Service/ShortUrl/MetamarkNetTest.php

@@ -40,7 +40,7 @@ class Zend_Service_ShortUrl_MetamarkNetTest extends PHPUnit_Framework_TestCase
      * @var Zend_Service_ShortUrl_MetamarkNet
      */
     protected $_s;
-    
+
     /**
      * Creates a new Zend_Service_ShortUrl_MetamarkNet object for each test method
      *
@@ -48,6 +48,8 @@ class Zend_Service_ShortUrl_MetamarkNetTest extends PHPUnit_Framework_TestCase
      */
     public function setUp ()
     {
+        Zend_Service_Abstract::setHttpClient(new Zend_Http_Client());
+
         $this->_s = new Zend_Service_ShortUrl_MetamarkNet();
     }
 
@@ -56,49 +58,49 @@ class Zend_Service_ShortUrl_MetamarkNetTest extends PHPUnit_Framework_TestCase
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->shorten('');
     }
-    
+
     public function testShortenIncorrectUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->shorten('wrongAdress.cccc');
     }
-    
+
     public function testShorten()
     {
         $urls = array(
             'http://framework.zend.com/'           => 'http://xrl.us/bh4ptf',
             'http://framework.zend.com/manual/en/' => 'http://xrl.us/bh4pth'
         );
-        
+
         foreach ($urls as $url => $shortenedUrl) {
             $this->assertEquals($shortenedUrl, $this->_s->shorten($url));
         }
     }
-    
+
     public function testUnshorten()
     {
         $urls = array(
             'http://framework.zend.com/'           => 'http://xrl.us/bh4ptf',
             'http://framework.zend.com/manual/en/' => 'http://xrl.us/bh4pth'
         );
-        
+
         foreach ($urls as $url => $shortenedUrl) {
             $this->assertEquals($url, $this->_s->unshorten($shortenedUrl));
         }
     }
-    
+
     public function testUnshortenEmptyUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->unshorten('');
     }
-    
+
     public function testUnshortenIncorrectUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->unshorten('wrongAdress.cccc');
     }
-    
+
     public function testUnshortenWrongUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');

+ 10 - 8
tests/Zend/Service/ShortUrl/TinyUrlComTest.php

@@ -47,6 +47,8 @@ class Zend_Service_ShortUrl_TinyUrlComTest extends PHPUnit_Framework_TestCase
      */
     public function setUp ()
     {
+        Zend_Service_Abstract::setHttpClient(new Zend_Http_Client());
+
         $this->_s = new Zend_Service_ShortUrl_TinyUrlCom();
     }
 
@@ -55,49 +57,49 @@ class Zend_Service_ShortUrl_TinyUrlComTest extends PHPUnit_Framework_TestCase
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->shorten('');
     }
-    
+
     public function testShortenIncorrectUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->shorten('wrongAdress.cccc');
     }
-    
+
     public function testShorten()
     {
         $urls = array(
             'http://framework.zend.com/'           => 'http://tinyurl.com/rxtuq',
             'http://framework.zend.com/manual/en/' => 'http://tinyurl.com/ynvdzf'
         );
-        
+
         foreach ($urls as $url => $shortenedUrl) {
             $this->assertEquals($shortenedUrl, $this->_s->shorten($url));
         }
     }
-    
+
     public function testUnshorten()
     {
         $urls = array(
             'http://framework.zend.com/'           => 'http://tinyurl.com/rxtuq',
             'http://framework.zend.com/manual/en/' => 'http://tinyurl.com/ynvdzf'
         );
-        
+
         foreach ($urls as $url => $shortenedUrl) {
             $this->assertEquals($url, $this->_s->unshorten($shortenedUrl));
         }
     }
-    
+
     public function testUnshortenEmptyUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->unshorten('');
     }
-    
+
     public function testUnshortenIncorrectUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');
         $this->_s->unshorten('wrongAdress.cccc');
     }
-    
+
     public function testUnshortenWrongUrlException()
     {
         $this->setExpectedException('Zend_Service_ShortUrl_Exception');