Exemplo n.º 1
0
 /**
  * @group read-only
  */
 public function testGetExtraHeaders()
 {
     Traackr\TraackrApi::setExtraHeaders($this->singleHeader);
     $h = Traackr\TraackrApi::getExtraHeaders();
     $this->assertInternalType('array', $h);
     $this->assertEquals(1, sizeof($h));
     $this->assertContains($this->singleHeader, $h);
     Traackr\TraackrApi::setExtraHeaders($this->arrayHeader);
     $h = Traackr\TraackrApi::getExtraHeaders();
     $this->assertInternalType('array', $h);
     $this->assertEquals(2, sizeof($h));
     $this->assertContains($this->arrayHeader[0], $h);
     $this->assertContains($this->arrayHeader[1], $h);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 public function tearDown()
 {
     Traackr\TraackrApi::setCustomerKey($this->savedCustomerKey);
 }
Exemplo n.º 4
0
 /**
  * @expectedException Traackr\InvalidCustomerKeyException
  */
 public function testSTagListInvalidCustomerKey()
 {
     Traackr\TraackrApi::setCustomerKey('xxxRandomInvalidCustomerKeyxxxx');
     Traackr\AccountMgmt::tagList();
 }
Exemplo n.º 5
0
<?php

// Load API library
require_once dirname(__FILE__) . '/../lib/TraackrApi.php';
// Set API key if none is defined in the env
// We want the env value to take precedence to enable testing against QA
if (!isset($_ENV['TRAACKR_API_KEY'])) {
    Traackr\TraackrApi::setApiKey('5adab9df789c2147116881f36785f6c3');
}
Traackr\TraackrApi::setExtraHeaders(array("X-TraackrApp-Session: TraackrAPI-UnitTest"));
Exemplo n.º 6
0
 /**
  * @group read-only
  */
 public function testLookupTwitter()
 {
     $twitterHandle = 'dchancogne';
     $inf = Traackr\Influencers::lookupTwitter($twitterHandle);
     // Check result is there
     $this->assertArrayHasKey('influencer', $inf, 'No influencer found');
     $this->assertArrayHasKey($twitterHandle, $inf['influencer'], 'Invalid influencer found');
     // Check appropriate fields are present
     $this->assertArrayHasKey('uid', $inf['influencer'][$twitterHandle], 'UID filed is missing');
     $this->assertArrayHasKey('name', $inf['influencer'][$twitterHandle], 'Name field missing');
     $this->assertArrayHasKey('description', $inf['influencer'][$twitterHandle], 'Description field missing');
     $this->assertArrayHasKey('title', $inf['influencer'][$twitterHandle], 'Title field missing');
     $this->assertArrayHasKey('location', $inf['influencer'][$twitterHandle], 'Location field missing');
     $this->assertArrayHasKey('avatar', $inf['influencer'][$twitterHandle], 'Avatar field missing');
     $this->assertArrayHasKey('reach', $inf['influencer'][$twitterHandle], 'Reach field missing');
     $this->assertArrayHasKey('resonance', $inf['influencer'][$twitterHandle], 'Resonance field missing');
     $this->assertArrayNotHasKey('channels', $inf['influencer'][$twitterHandle], 'Channels should not have be returned');
     $this->assertArrayNotHasKey('tags', $inf['influencer'][$twitterHandle], 'Tags field missing');
     // Check some values
     $this->assertEquals($this->infUid, $inf['influencer'][$twitterHandle]['uid'], 'Incorrect UID');
     $this->assertEquals($this->infName, $inf['influencer'][$twitterHandle]['name'], 'Incorrect name');
     // NOTE
     // Disable customer key so that 'show' doe not return tags b/c lookupTwitter doesn't currently
     Traackr\TraackrApi::setCustomerKey('');
     $inf = Traackr\Influencers::show($this->infUid);
     $twitter = Traackr\Influencers::lookupTwitter('dchancogne');
     $this->assertJsonStringEqualsJsonString(json_encode($inf['influencer'][$this->infUid]), json_encode($twitter['influencer']['dchancogne']));
 }