/** * Make sure subscription or unsubscription requests are allowed when * they're supposed to be. * @covers Hearsay\PubSubHubbubBundle\Controller\CallbackController */ public function testGoodSubscriptionVerified() { $request = Request::create('/pubsubhubbub?hub.mode=subscribe&' . 'hub.topic=http://rss.topic.com&' . 'hub.challenge=print_this&' . 'hub.lease_seconds=100'); $this->topic->expects($this->any())->method('getTopicUrl')->will($this->returnValue('http://rss.topic.com/')); $this->topic->expects($this->any())->method('isSubscribeAllowed')->will($this->returnValue(true)); // We shouldn't receive a notification $this->notificationHandler->expects($this->never())->method('handle'); $controller = new CallbackController($this->topicProvider, $this->notificationHandler, $this->getContainer($request), $this->logger); $response = $controller->callbackAction($this->identifier); // And we should be successful $this->assertTrue($response->isSuccessful()); $this->assertEquals('print_this', $response->getContent()); }
/** * Get the callback URL which should be used for handling notifications and * verifying requests related to the given topic. * @param TopicInterface The topic being processed. * @return string The callback URL. */ protected function getCallbackUrl(TopicInterface $topic) { return $this->generator->generate($this->callbackRoute, array('topicId' => $topic->getTopicId()), true); }