Example #1
0
 /**
  * Tests that the same topLinks information is returned when looking up links for
  * influencers by tags or by influencer uids
  */
 public function testParams()
 {
     // Add Tags
     $tagAddParams = array('influencers' => array($this->infUid, $this->infUid2), 'tags' => array($this->testTag));
     Traackr\Influencers::tagAdd($tagAddParams);
     $infs = array($this->infUid, $this->infUid2);
     $tags = array($this->testTag);
     // First test that we have top links to compare
     $posts = Traackr\Analysis::toplinks(array('influencers' => $infs, 'count' => 1));
     # 1 post
     $this->assertCount(1, $posts['links']);
     #just 1 post see above
     $this->assertTrue(in_array($posts['links'][0]['linkbacks'][0]['influencer_uid'], $infs));
     Traackr\TraackrApi::setJsonOutput(true);
     $posts1 = Traackr\Analysis::toplinks(array('influencers' => $infs));
     $posts2 = Traackr\Analysis::toplinks(array('tags' => $tags));
     $this->assertJsonStringEqualsJsonString($posts1, $posts2);
     // Remove Tags
     $tagRemoveParams = array('all' => true, 'tags' => array($this->testTag));
     Traackr\Influencers::tagRemove($tagRemoveParams);
 }
 public function testTagList()
 {
     $tags = Traackr\AccountMgmt::tagList();
     // $tags_list = array_reduce($tags, function(&$results, $item) { $results[] = $item['tag']; }, array());
     foreach ($tags['account']['tags'] as $tag) {
         if ($tag['tag'] == $this->infTag) {
             $this->assertSame(0, $tag['ref_count']);
         }
     }
     Traackr\Influencers::tagAdd(array('influencers' => $this->infUid, 'tags' => $this->infTag));
     $tags = Traackr\AccountMgmt::tagList();
     foreach ($tags['account']['tags'] as $tag) {
         if ($tag['tag'] == $this->infTag) {
             $this->assertSame(1, $tag['ref_count']);
         }
     }
     $tags = Traackr\AccountMgmt::tagList(array('tag_prefix_filter' => 'traackr-api'));
     foreach ($tags['account']['tags'] as $tag) {
         if ($tag['tag'] == $this->infTag) {
             $this->assertSame(1, $tag['ref_count']);
         }
     }
     Traackr\Influencers::tagRemove(array('influencers' => $this->infUid, 'tags' => $this->infTag));
 }
 public function testSearch()
 {
     Traackr\Influencers::tagAdd(array('influencers' => $this->infUid, 'tags' => $this->infTag));
     sleep(1);
     // Make sure tag operation is done indexing
     // Finds result with prefix
     $inf = Traackr\Influencers::search(array('keywords' => 'traackr', 'tags' => 'traackr-api-', 'is_tag_prefix' => true));
     $this->assertGreaterThan(0, $inf['influencers'], 'No results found');
     // No result with exact tag match
     $inf = Traackr\Influencers::search(array('keywords' => 'traackr', 'tags' => 'traackr-api-', 'is_tag_prefix' => false));
     $this->assertCount(0, $inf['influencers'], 'Results found');
     // Test tags_exclusive
     Traackr\Influencers::tagAdd(array('influencers' => $this->infUid2, 'tags' => array($this->infTag, $this->infTag2)));
     sleep(1);
     // Make sure tag operation is done indexing
     $infs = Traackr\Influencers::search(array('keywords' => 'traackr', 'tags' => $this->infTag));
     $this->assertCount(2, $infs['influencers'], 'No results found');
     $infs = Traackr\Influencers::search(array('keywords' => 'traackr', 'tags' => $this->infTag, 'tags_exclusive' => $this->infTag2));
     $this->assertCount(1, $infs['influencers'], 'Results found');
     Traackr\Influencers::tagRemove(array('influencers' => array($this->infUid, $this->infUid2), 'tags' => array($this->infTag, $this->infTag2)));
 }