Browse Source

ZF-10231
Fixed various unit test issues as a result of ZF-10069 and ZF-9891

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

ralph 15 years ago
parent
commit
50df59be93

+ 100 - 38
tests/Zend/Feed/Pubsubhubbub/Subscriber/CallbackTest.php

@@ -148,15 +148,23 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
 
     public function testValidatesValidHttpGetData()
     {
+        
+        $mockReturnValue = $this->getMock('Result', array('toArray'));
+        $mockReturnValue->expects($this->any())->method('toArray')->will($this->returnValue(array(
+                'verify_token' => hash('sha256', 'cba')
+            )));
+
         $this->_tableGateway->expects($this->any())
             ->method('find')
             ->with($this->equalTo('verifytokenkey'))
             ->will($this->returnValue($this->_rowset));
         $this->_rowset->expects($this->any())
             ->method('current')
-            ->will($this->returnValue(array(
-                'verify_token' => hash('sha256', 'cba')
-            )));
+            ->will($this->returnValue($mockReturnValue));
+        $this->_rowset->expects($this->any())
+            ->method('count')
+            ->will($this->returnValue(1));
+
         $this->assertTrue($this->_callback->isValidHubVerification($this->_get));
     }
 
@@ -192,6 +200,12 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
     
     public function testReturnsTrueIfModeSetAsUnsubscribeFromHttpGetData()
     {
+        
+        $mockReturnValue = $this->getMock('Result', array('toArray'));
+        $mockReturnValue->expects($this->any())->method('toArray')->will($this->returnValue(array(
+                'verify_token' => hash('sha256', 'cba')
+            )));
+        
         $this->_get['hub_mode'] = 'unsubscribe';
         $this->_tableGateway->expects($this->any())
             ->method('find')
@@ -199,9 +213,12 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
             ->will($this->returnValue($this->_rowset));
         $this->_rowset->expects($this->any())
             ->method('current')
-            ->will($this->returnValue(array(
-                'verify_token' => hash('sha256', 'cba')
-            )));
+            ->will($this->returnValue($mockReturnValue));
+        // require for the count call on the rowset in Model/Subscription
+        $this->_rowset->expects($this->any())
+            ->method('count')
+            ->will($this->returnValue(1));
+            
         $this->assertTrue($this->_callback->isValidHubVerification($this->_get));
     }
 
@@ -249,15 +266,24 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
             ->method('find')
             ->with($this->equalTo('verifytokenkey'))
             ->will($this->returnValue($this->_rowset));
-        $rowdata = new stdClass;
-        $rowdata->id = 'verifytokenkey';
-        $rowdata->verify_token = hash('sha256', 'cba');
+        
         $t = new Zend_Date;
-        $rowdata->created_time = $t->get(Zend_Date::TIMESTAMP);
-        $rowdata->lease_seconds = 10000;
+        $rowdata = array(
+            'id' => 'verifytokenkey',
+            'verify_token' => hash('sha256', 'cba'),
+            'created_time' => $t->get(Zend_Date::TIMESTAMP),
+            'lease_seconds' => 10000
+            );
+        
+        $row = new Zend_Db_Table_Row(array('data' => $rowdata));
+            
         $this->_rowset->expects($this->any())
             ->method('current')
-            ->will($this->returnValue($rowdata));
+            ->will($this->returnValue($row));
+        // require for the count call on the rowset in Model/Subscription
+        $this->_rowset->expects($this->any())
+            ->method('count')
+            ->will($this->returnValue(1));
             
         $this->_tableGateway->expects($this->once())
             ->method('update')
@@ -280,16 +306,25 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
             ->method('find')
             ->with($this->equalTo('verifytokenkey'))
             ->will($this->returnValue($this->_rowset));
-        $rowdata = new stdClass;
-        $rowdata->id = 'verifytokenkey';
-        $rowdata->verify_token = hash('sha256', 'cba');
+
         $t = new Zend_Date;
-        $rowdata->created_time = $t->get(Zend_Date::TIMESTAMP);
-        $rowdata->lease_seconds = 10000;
+        $rowdata = array(
+            'id' => 'verifytokenkey',
+            'verify_token' => hash('sha256', 'cba'),
+            'created_time' => $t->get(Zend_Date::TIMESTAMP),
+            'lease_seconds' => 10000
+            );
+        
+        $row = new Zend_Db_Table_Row(array('data' => $rowdata));    
+            
         $this->_rowset->expects($this->any())
             ->method('current')
-            ->will($this->returnValue($rowdata));
-            
+            ->will($this->returnValue($row));
+        // require for the count call on the rowset in Model/Subscription
+        $this->_rowset->expects($this->any())
+            ->method('count')
+            ->will($this->returnValue(1));
+
         $this->_tableGateway->expects($this->once())
             ->method('update')
             ->with(
@@ -316,14 +351,23 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
             ->method('find')
             ->with($this->equalTo('verifytokenkey'))
             ->will($this->returnValue($this->_rowset));
-        $rowdata = new stdClass;
-        $rowdata->id = 'verifytokenkey';
-        $rowdata->verify_token = hash('sha256', 'cba');
-        $t = time();
-        $rowdata->created_time = $t;
+
+        $t = new Zend_Date;
+        $rowdata = array(
+            'id' => 'verifytokenkey',
+            'verify_token' => hash('sha256', 'cba'),
+            'created_time' => time()
+            );
+        
+        $row = new Zend_Db_Table_Row(array('data' => $rowdata));    
+            
         $this->_rowset->expects($this->any())
             ->method('current')
-            ->will($this->returnValue($rowdata));
+            ->will($this->returnValue($row));
+        // require for the count call on the rowset in Model/Subscription
+        $this->_rowset->expects($this->any())
+            ->method('count')
+            ->will($this->returnValue(1));
         
         $this->_callback->handle(array());
         $this->assertTrue($this->_callback->getHttpResponse()->getHttpResponseCode() == 200);
@@ -370,15 +414,24 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
             ->method('find')
             ->with($this->equalTo('verifytokenkey'))
             ->will($this->returnValue($this->_rowset));
-        $rowdata = new stdClass;
-        $rowdata->id = 'verifytokenkey';
-        $rowdata->verify_token = hash('sha256', 'cba');
-        $t = time();
-        $rowdata->created_time = $t;
+
+        $rowdata = array(
+            'id' => 'verifytokenkey',
+            'verify_token' => hash('sha256', 'cba'),
+            'created_time' => time(),
+            'lease_seconds' => 10000
+            );
+        
+        $row = new Zend_Db_Table_Row(array('data' => $rowdata));    
+            
         $this->_rowset->expects($this->any())
             ->method('current')
-            ->will($this->returnValue($rowdata));
-        
+            ->will($this->returnValue($row));
+        // require for the count call on the rowset in Model/Subscription
+        $this->_rowset->expects($this->any())
+            ->method('count')
+            ->will($this->returnValue(1));
+
         $this->_callback->handle(array());
         $this->assertTrue($this->_callback->getHttpResponse()->getHttpResponseCode() == 200);
     }
@@ -395,14 +448,23 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
             ->method('find')
             ->with($this->equalTo('verifytokenkey'))
             ->will($this->returnValue($this->_rowset));
-        $rowdata = new stdClass;
-        $rowdata->id = 'verifytokenkey';
-        $rowdata->verify_token = hash('sha256', 'cba');
-        $t = time();
-        $rowdata->created_time = $t;
+
+        $rowdata = array(
+            'id' => 'verifytokenkey',
+            'verify_token' => hash('sha256', 'cba'),
+            'created_time' => time(),
+            'lease_seconds' => 10000
+            );
+        
+        $row = new Zend_Db_Table_Row(array('data' => $rowdata));    
+            
         $this->_rowset->expects($this->any())
             ->method('current')
-            ->will($this->returnValue($rowdata));
+            ->will($this->returnValue($row));
+        // require for the count call on the rowset in Model/Subscription
+        $this->_rowset->expects($this->any())
+            ->method('count')
+            ->will($this->returnValue(1));
         
         $this->_callback->handle(array());
         $this->assertTrue($this->_callback->getHttpResponse()->getHeader('X-Hub-On-Behalf-Of') == 1);

+ 1 - 1
tests/Zend/Feed/Reader/Entry/RssTest.php

@@ -1909,7 +1909,7 @@ class Zend_Feed_Reader_Entry_RssTest extends PHPUnit_Framework_TestCase
         $entry = $feed->current();
         $fdate = $entry->getDateModified();
         $edate = new Zend_Date;
-        $edate->set('2010-01-04T08:14:00-0600', Zend_Date::ISO_8601);
+        $edate->set('2010-01-04T02:14:00-0600', Zend_Date::ISO_8601);
         Zend_Registry::getInstance()->offsetUnset('Zend_Locale');
         $this->assertTrue($edate->equals($fdate));
     }

+ 1 - 1
tests/Zend/Feed/Reader/Feed/RssTest.php

@@ -2145,7 +2145,7 @@ class Zend_Feed_Reader_Feed_RssTest extends PHPUnit_Framework_TestCase
         );
         $fdate = $feed->getDateModified();
         $edate = new Zend_Date;
-        $edate->set('2010-01-04T08:14:00-0600', Zend_Date::ISO_8601);
+        $edate->set('2010-01-04T02:14:00-0600', Zend_Date::ISO_8601);
         Zend_Registry::getInstance()->offsetUnset('Zend_Locale');
         $this->assertTrue($edate->equals($fdate));
     }