|
|
@@ -40,7 +40,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
public function setUp()
|
|
|
{
|
|
|
$this->_callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback;
|
|
|
-
|
|
|
+
|
|
|
$this->_adapter = $this->_getCleanMock(
|
|
|
'Zend_Db_Adapter_Abstract'
|
|
|
);
|
|
|
@@ -50,7 +50,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$this->_rowset = $this->_getCleanMock(
|
|
|
'Zend_Db_Table_Rowset_Abstract'
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
$this->_tableGateway->expects($this->any())->method('getAdapter')
|
|
|
->will($this->returnValue($this->_adapter));
|
|
|
$storage = new Zend_Feed_Pubsubhubbub_Model_Subscription($this->_tableGateway);
|
|
|
@@ -148,7 +148,7 @@ 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')
|
|
|
@@ -197,15 +197,15 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
unset($this->_get['hub_verify_token']);
|
|
|
$this->assertFalse($this->_callback->isValidHubVerification($this->_get));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
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')
|
|
|
@@ -218,7 +218,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('count')
|
|
|
->will($this->returnValue(1));
|
|
|
-
|
|
|
+
|
|
|
$this->assertTrue($this->_callback->isValidHubVerification($this->_get));
|
|
|
}
|
|
|
|
|
|
@@ -266,7 +266,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
->method('find')
|
|
|
->with($this->equalTo('verifytokenkey'))
|
|
|
->will($this->returnValue($this->_rowset));
|
|
|
-
|
|
|
+
|
|
|
$t = new Zend_Date;
|
|
|
$rowdata = array(
|
|
|
'id' => 'verifytokenkey',
|
|
|
@@ -274,9 +274,10 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
'created_time' => $t->get(Zend_Date::TIMESTAMP),
|
|
|
'lease_seconds' => 10000
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
+ require_once 'Zend/Db/Table/Row.php';
|
|
|
$row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
-
|
|
|
+
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('current')
|
|
|
->will($this->returnValue($row));
|
|
|
@@ -284,7 +285,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('count')
|
|
|
->will($this->returnValue(1));
|
|
|
-
|
|
|
+
|
|
|
$this->_tableGateway->expects($this->once())
|
|
|
->method('update')
|
|
|
->with(
|
|
|
@@ -294,8 +295,8 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$this->_adapter->expects($this->once())
|
|
|
->method('quoteInto')
|
|
|
->with($this->equalTo('id = ?'), $this->equalTo('verifytokenkey'))
|
|
|
- ->will($this->returnValue('id = \'verifytokenkey\''));
|
|
|
-
|
|
|
+ ->will($this->returnValue('id = \'verifytokenkey\''));
|
|
|
+
|
|
|
$this->_callback->handle($this->_get);
|
|
|
$this->assertTrue($this->_callback->getHttpResponse()->getHttpResponseCode() == 200);
|
|
|
}
|
|
|
@@ -314,9 +315,9 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
'created_time' => $t->get(Zend_Date::TIMESTAMP),
|
|
|
'lease_seconds' => 10000
|
|
|
);
|
|
|
-
|
|
|
- $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
-
|
|
|
+
|
|
|
+ $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
+
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('current')
|
|
|
->will($this->returnValue($row));
|
|
|
@@ -346,7 +347,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$_SERVER['CONTENT_TYPE'] = 'application/atom+xml';
|
|
|
$feedXml = file_get_contents(dirname(__FILE__) . '/_files/atom10.xml');
|
|
|
$GLOBALS['HTTP_RAW_POST_DATA'] = $feedXml; // dirty alternative to php://input
|
|
|
-
|
|
|
+
|
|
|
$this->_tableGateway->expects($this->any())
|
|
|
->method('find')
|
|
|
->with($this->equalTo('verifytokenkey'))
|
|
|
@@ -358,9 +359,9 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
'verify_token' => hash('sha256', 'cba'),
|
|
|
'created_time' => time()
|
|
|
);
|
|
|
-
|
|
|
- $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
-
|
|
|
+
|
|
|
+ $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
+
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('current')
|
|
|
->will($this->returnValue($row));
|
|
|
@@ -368,11 +369,11 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('count')
|
|
|
->will($this->returnValue(1));
|
|
|
-
|
|
|
+
|
|
|
$this->_callback->handle(array());
|
|
|
$this->assertTrue($this->_callback->getHttpResponse()->getHttpResponseCode() == 200);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public function testRespondsToInvalidFeedUpdateNotPostWith404Response()
|
|
|
{ // yes, this example makes no sense for GET - I know!!!
|
|
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
|
|
@@ -380,7 +381,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$_SERVER['CONTENT_TYPE'] = 'application/atom+xml';
|
|
|
$feedXml = file_get_contents(dirname(__FILE__) . '/_files/atom10.xml');
|
|
|
$GLOBALS['HTTP_RAW_POST_DATA'] = $feedXml;
|
|
|
-
|
|
|
+
|
|
|
$this->_callback->handle(array());
|
|
|
$this->assertTrue($this->_callback->getHttpResponse()->getHttpResponseCode() == 404);
|
|
|
}
|
|
|
@@ -409,7 +410,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$_SERVER['CONTENT_TYPE'] = 'application/rss+xml';
|
|
|
$feedXml = file_get_contents(dirname(__FILE__) . '/_files/atom10.xml');
|
|
|
$GLOBALS['HTTP_RAW_POST_DATA'] = $feedXml;
|
|
|
-
|
|
|
+
|
|
|
$this->_tableGateway->expects($this->any())
|
|
|
->method('find')
|
|
|
->with($this->equalTo('verifytokenkey'))
|
|
|
@@ -421,9 +422,9 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
'created_time' => time(),
|
|
|
'lease_seconds' => 10000
|
|
|
);
|
|
|
-
|
|
|
- $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
-
|
|
|
+
|
|
|
+ $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
+
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('current')
|
|
|
->will($this->returnValue($row));
|
|
|
@@ -443,7 +444,7 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$_SERVER['CONTENT_TYPE'] = 'application/atom+xml';
|
|
|
$feedXml = file_get_contents(dirname(__FILE__) . '/_files/atom10.xml');
|
|
|
$GLOBALS['HTTP_RAW_POST_DATA'] = $feedXml;
|
|
|
-
|
|
|
+
|
|
|
$this->_tableGateway->expects($this->any())
|
|
|
->method('find')
|
|
|
->with($this->equalTo('verifytokenkey'))
|
|
|
@@ -455,9 +456,9 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
'created_time' => time(),
|
|
|
'lease_seconds' => 10000
|
|
|
);
|
|
|
-
|
|
|
- $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
-
|
|
|
+
|
|
|
+ $row = new Zend_Db_Table_Row(array('data' => $rowdata));
|
|
|
+
|
|
|
$this->_rowset->expects($this->any())
|
|
|
->method('current')
|
|
|
->will($this->returnValue($row));
|
|
|
@@ -465,11 +466,11 @@ class Zend_Feed_Pubsubhubbub_Subscriber_CallbackTest extends PHPUnit_Framework_T
|
|
|
$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);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
protected function _getCleanMock($className) {
|
|
|
$class = new ReflectionClass($className);
|
|
|
$methods = $class->getMethods();
|