コード例 #1
0
 public function testInsertHashtag()
 {
     $this->debug("Begin testInsertHashtagByHashtagName");
     $res = $this->dao->getHashtag('#mwc2013', 'twitter');
     $this->assertNull($res);
     $res = $this->dao->insertHashtag('#mwc2013', 'twitter');
     $this->assertEqual($res, 4);
     $res = $this->dao->getHashtag('#mwc2013', 'twitter');
     $this->assertNotNull($res);
     $this->assertEqual($res->hashtag, '#mwc2013');
     $this->debug("End testInsertHashtagByHashtagName");
 }
コード例 #2
0
 public function testInsertHashtags()
 {
     $ht = array('bob', 'dole');
     $this->dao->insertHashtags($ht, '39089424330978176', 'twitter');
     $this->dao->insertHashtags($ht, '39089424330978177', 'twitter');
     $res1 = $this->dao->getHashtagsForPost('39089424330978176');
     $res2 = $this->dao->getHashtagsForPost('39089424330978177');
     $this->assertEqual(sizeof($res1), 2);
     $this->assertEqual(sizeof($res2), 2);
     $this->assertEqual($res2[1]['hashtag_id'], 4);
     $res3 = $this->dao->getHashtagInfoForTag('dole');
     $this->assertEqual($res3['count_cache'], 2);
     $res4 = $this->dao->getHashtagsForPostHID(3);
     $this->assertEqual(sizeof($res4), 2);
     $this->assertEqual($res4[0]['post_id'], '39089424330978176');
 }
コード例 #3
0
 public function testInsertHashtags()
 {
     $ht = array('bob', 'dole');
     $this->hashtagpost_dao->insertHashtagPosts($ht, '39089424330978176', 'twitter');
     $this->hashtagpost_dao->insertHashtagPosts($ht, '39089424330978177', 'twitter');
     $res1 = $this->hashtagpost_dao->getHashtagsForPost('39089424330978176', 'twitter');
     $res2 = $this->hashtagpost_dao->getHashtagsForPost('39089424330978177', 'twitter');
     $this->assertEqual(sizeof($res1), 2);
     $this->assertEqual(sizeof($res2), 2);
     $this->assertEqual($res2[1]['hashtag_id'], 3);
     //setup generated 1 prev hashtag
     $res3 = $this->hashtag_dao->getHashtag('dole', 'twitter');
     $this->assertEqual($res3->count_cache, 2);
     $res4 = $this->hashtagpost_dao->getHashtagPostsByHashtagID(2);
     //setup has generated 2 prev hashtags
     $this->assertEqual(sizeof($res4), 2);
     $this->assertEqual($res4[0]['post_id'], '39089424330978176');
 }
コード例 #4
0
 /**
  * This method tests basic handling of the data structures generated by the json parser, including entity and
  * user information. In add'n, it tests new-style rt handling.
  */
 public function testAddPostAndAssociatedInfo()
 {
     list($post, $entities, $user_array) = $this->buildStreamPostArray1();
     $dao = new PostMySQLDAO();
     $dao->addPostAndAssociatedInfo($post, $entities, $user_array);
     $post_orig = $dao->getPost('39088587140108288', 'twitter');
     $this->assertEqual($post_orig->post_text, '@joanwalsh RT @AntDeRosa Hillary #Clinton provides perhaps the best argument defending Planned ' . 'Parenthood (Video, 2009) http://j.mp/eZbWh0');
     $this->assertEqual($post_orig->post_id, '39088587140108288');
     $this->assertEqual($post_orig->retweet_count_cache, 1);
     $this->assertEqual($post_orig->old_retweet_count_cache, 0);
     $this->assertEqual($post_orig->in_retweet_of_post_id, null);
     $post_rt = $dao->getPost('39089424620978176', 'twitter');
     $this->assertEqual($post_rt->post_id, '39089424620978176');
     $this->assertEqual($post_rt->post_text, 'RT @HeyJacquiDey: @joanwalsh RT @AntDeRosa ' . 'Hillary #Clinton provides perhaps the best argument defending Planned Parenthood (Video, 2009) ...');
     $this->assertEqual($post_rt->retweet_count_cache, 0);
     $this->assertEqual($post_rt->old_retweet_count_cache, 0);
     $this->assertEqual($post_rt->in_retweet_of_post_id, '39088587140108288');
     $this->assertEqual($post_rt->in_rt_of_user_id, '136881432');
     $hashtag_dao = new HashtagMySQLDAO();
     $hashtagpost_dao = new HashtagPostMySQLDAO();
     $m_dao = new MentionMySQLDAO();
     $h = $hashtag_dao->getHashtag('Clinton', 'twitter');
     $this->assertEqual($h->count_cache, 2);
     $hp = $hashtagpost_dao->getHashtagsForPost('39088587140108288', 'twitter');
     $this->assertEqual(sizeof($hp), 1);
     $this->assertEqual($hp[0]['post_id'], '39088587140108288');
     $hp = $hashtagpost_dao->getHashtagsForPost('39089424620978176', 'twitter');
     $this->assertEqual($hp[0]['post_id'], '39089424620978176');
     $this->assertEqual($hp[0]['hashtag_id'], 3);
     $hph = $hashtagpost_dao->getHashtagPostsByHashtagID(3);
     $this->assertEqual(sizeof($hph), 2);
     $this->assertEqual($hph[1]['post_id'], '39089424620978176');
     $m = $m_dao->getMentionInfoUserName('joanwalsh');
     $this->assertEqual($m['count_cache'], 2);
     $mp = $m_dao->getMentionsForPost('39089424620978176');
     $this->assertEqual(sizeof($mp), 3);
     $this->assertEqual($mp[1]['mention_id'], 2);
     $mpm = $m_dao->getMentionsForPostMID(2);
     $this->assertEqual(sizeof($mpm), 2);
     $this->assertEqual($mpm[0]['post_id'], '39088587140108288');
 }
コード例 #5
0
 public function testDeleteExistingInstanceWithTweetSearchWithPrivilegesWithOtherOwners()
 {
     $this->debug(__METHOD__);
     //Not admin with access privs, with other owners (delete owner instance and NOT instance)
     $builders = array();
     $builders[] = FixtureBuilder::build('instances', array('id' => 2, 'network_user_id' => 12, 'network_username' => 'tuinstance', 'network' => 'twitter'));
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 2, 'oauth_access_token' => 'xxx', 'oauth_access_token_secret' => 'yyy'));
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 2, 'instance_id' => 2, 'oauth_access_token' => 'xxx', 'oauth_access_token_secret' => 'yyy'));
     $instance_dao = new InstanceMySQLDAO();
     $owner_instance_dao = new OwnerInstanceMySQLDAO();
     $instance_hashtag_dao = new InstanceHashtagMySQLDAO();
     //before builder
     $instance = $instance_dao->get(2);
     $this->assertNotNull($instance);
     $instances_hashtags = $instance_hashtag_dao->getByInstance($instance->id);
     $this->assertEqual(sizeof($instances_hashtags), 0);
     $builder = $this->buildHashtagData(2);
     //after builder
     $hashtag_dao = new HashtagMySQLDAO();
     $hashtagpost_dao = new HashtagPostMySQLDAO();
     $hashtags = $hashtagpost_dao->getHashtagsForPost(1, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     $hashtags = $hashtagpost_dao->getHashtagsForPost(2, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     //instances hashtags should be deleted
     $instances_hashtags = $instance_hashtag_dao->getByInstance(2);
     $this->assertEqual(sizeof($instances_hashtags), 2);
     //hashtag should be deleted
     $hashtag = $hashtag_dao->getHashtagByID(1);
     $this->assertEqual(sizeof($hashtag), 1);
     $hashtag = $hashtag_dao->getHashtagByID(2);
     $this->assertEqual(sizeof($hashtag), 1);
     //Should delete the owner instance but leave the instance alone
     $this->simulateLogin('*****@*****.**', false, true);
     $_POST['action'] = "Delete";
     $_POST["instance_id"] = 2;
     $_POST['csrf_token'] = parent::CSRF_TOKEN;
     $controller = new AccountConfigurationController(true);
     //before
     $instance = $instance_dao->get(2);
     $this->assertNotNull($instance);
     $owner_instances = $owner_instance_dao->getByInstance(2);
     $this->assertNotNull($owner_instances);
     $this->assertIsA($owner_instances, 'Array');
     $this->assertEqual(sizeof($owner_instances), 2);
     //process controller
     $controller->go();
     //hashtags posts should be deleted
     $hashtags = $hashtagpost_dao->getHashtagsForPost(1, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     $hashtags = $hashtagpost_dao->getHashtagsForPost(2, 'twitter');
     $this->assertEqual(sizeof($hashtags), 1);
     //instances hashtags should NOT be deleted
     $instances_hashtags = $instance_hashtag_dao->getByInstance(2);
     $this->assertEqual(sizeof($instances_hashtags), 2);
     //hashtag should NOT be deleted
     $hashtag = $hashtag_dao->getHashtagByID(1);
     $this->assertEqual(sizeof($hashtag), 1);
     $hashtag = $hashtag_dao->getHashtagByID(2);
     $this->assertEqual(sizeof($hashtag), 1);
     $this->debug('Still running');
     //instance should NOT be deleted
     $instance = $instance_dao->get(2);
     $this->assertNotNull($instance);
     //just one owner_instance should be deleted
     $owner_instances = $owner_instance_dao->getByInstance(2);
     $this->assertIsA($owner_instances, 'Array');
     $this->assertEqual(sizeof($owner_instances), 1);
     $v_mgr = $controller->getViewManager();
     $success_msgs = $v_mgr->getTemplateDataItem('success_msgs');
     $this->assertNotNull($success_msgs);
     $this->assertEqual($success_msgs['account'], 'Account deleted.');
     $this->assertNull($v_mgr->getTemplateDataItem('error_msg'));
 }