public function testNetworkIssued() { $collection = $this->site->buildCommentsCollection("title", "articleId", "http://livefyre.com"); $this->assertFalse($collection->isNetworkIssued()); $collection->getData()->setTopics(array(Topic::create($this->site, "ID", "LABEL"))); $this->assertFalse($collection->isNetworkIssued()); $collection->getData()->setTopics(array(Topic::create($this->site->getNetwork(), "ID", "LABEL"))); $this->assertTrue($collection->isNetworkIssued()); }
public function testTopicStreamCursor() { $topicId = "topic"; $label = "label"; $tsResource = sprintf("urn:livefyre:%s.fyre.co:topic=%s:topicStream", $this->network->getNetworkName(), $topicId); $topic = Topic::create($this->network, $topicId, $label); $cursor = CursorFactory::getTopicStreamCursor($this->network, $topic); $this->assertEquals($tsResource, $cursor->getData()->getResource()); $cursor = CursorFactory::getTopicStreamCursor($this->network, $topic, $this::LIMIT, time()); $this->assertEquals($tsResource, $cursor->getData()->getResource()); $this->assertEquals($this::LIMIT, $cursor->getData()->getLimit()); }
public static function createOrUpdateTopics(Core $core, $topicMap) { $topics = array(); $json = array(); foreach ($topicMap as $id => $label) { if (empty($label) || strlen($label) > 128) { throw new \InvalidArgumentException("topic label should be 128 char or under and not empty"); } $topic = Topic::create($core, $id, $label); $topics[] = $topic; $json[] = $topic->serializeToJson(); } $data = json_encode(array("topics" => $json)); $url = self::getTopicsUrl($core); Client::POST($url, self::getHeaders($core), $data); return $topics; }