Пример #1
0
 public function testNotifiesHubAndReportsFail()
 {
     PubSubHubbub::setHttpClient($this->getClientFail());
     $client = PubSubHubbub::getHttpClient();
     $this->_publisher->addHubUrl('http://www.example.com/hub');
     $this->_publisher->addUpdatedTopicUrl('http://www.example.com/topic');
     $this->_publisher->setParameter('foo', 'bar');
     $this->_publisher->notifyAll();
     $this->assertFalse($this->_publisher->isSuccess());
 }
Пример #2
0
 /**
  * Get a basic prepared HTTP client for use
  *
  * @return \Zend\Http\Client
  */
 protected function _getHttpClient()
 {
     $client = PubSubHubbub::getHttpClient();
     $client->setMethod(HttpRequest::METHOD_POST);
     $client->setOptions(array('useragent' => 'Zend_Feed_Pubsubhubbub_Subscriber/' . Version::VERSION));
     return $client;
 }
Пример #3
0
 /**
  * Get a basic prepared HTTP client for use
  *
  * @return \Zend\HTTP\Client
  */
 protected function _getHttpClient()
 {
     $client = PubSubHubbub::getHttpClient();
     $client->setMethod(\Zend\HTTP\Client::POST);
     $client->setConfig(array('useragent' => 'Zend_Feed_Pubsubhubbub_Publisher/' . \Zend\Version::VERSION));
     $params = array();
     $params[] = 'hub.mode=publish';
     $topics = $this->getUpdatedTopicUrls();
     if (empty($topics)) {
         throw new Exception('No updated topic URLs' . ' have been set');
     }
     foreach ($topics as $topicUrl) {
         $params[] = 'hub.url=' . urlencode($topicUrl);
     }
     $optParams = $this->getParameters();
     foreach ($optParams as $name => $value) {
         $params[] = urlencode($name) . '=' . urlencode($value);
     }
     $paramString = implode('&', $params);
     $client->setRawData($paramString);
     return $client;
 }
Пример #4
0
 /**
  * Get a basic prepared HTTP client for use
  *
  * @return \Zend\Http\Client
  * @throws Exception\RuntimeException
  */
 protected function _getHttpClient()
 {
     $client = PubSubHubbub::getHttpClient();
     $client->setMethod(HttpRequest::METHOD_POST);
     $client->setOptions(['useragent' => 'Zend_Feed_Pubsubhubbub_Publisher/' . Version::VERSION]);
     $params = [];
     $params[] = 'hub.mode=publish';
     $topics = $this->getUpdatedTopicUrls();
     if (empty($topics)) {
         throw new Exception\RuntimeException('No updated topic URLs' . ' have been set');
     }
     foreach ($topics as $topicUrl) {
         $params[] = 'hub.url=' . urlencode($topicUrl);
     }
     $optParams = $this->getParameters();
     foreach ($optParams as $name => $value) {
         $params[] = urlencode($name) . '=' . urlencode($value);
     }
     $paramString = implode('&', $params);
     $client->setRawBody($paramString);
     return $client;
 }
Пример #5
0
 public function testCanSetCustomHttpClient()
 {
     PubSubHubbub\PubSubHubbub::setHttpClient(new Pubsub());
     $this->assertInstanceOf('ZendTest\\Feed\\PubSubHubbub\\Pubsub', PubSubHubbub\PubSubHubbub::getHttpClient());
 }
Пример #6
0
 /**
  * Get a basic prepared HTTP client for use
  *
  * @param  string $mode Must be "subscribe" or "unsubscribe"
  * @return \Zend\Http\Client
  */
 protected function _getHttpClient()
 {
     $client = PubSubHubbub::getHttpClient();
     $client->setMethod(\Zend\Http\Client::POST);
     $client->setConfig(array('useragent' => 'Zend_Feed_Pubsubhubbub_Subscriber/' . \Zend\Version::VERSION));
     return $client;
 }