Ejemplo n.º 1
0
 public function testInsertMentions()
 {
     $mentions = array(array('user_id' => 136881432, 'user_name' => 'HeyJacquiDey'), array('user_id' => 1106501, 'user_name' => 'joanwalsh'), array('user_id' => 1140451, 'user_name' => 'AntDeRosa'), array('user_id' => 1140451, 'user_name' => 'AntDeRosa'));
     $this->dao->insertMentions($mentions, '39089424620978176', 123456, 'twitter');
     $this->dao->insertMentions($mentions, '39089424620978177', 123457, 'twitter');
     $res1 = $this->dao->getMentionsForPost('39089424620978176');
     $res2 = $this->dao->getMentionsForPost('39089424620978177');
     // there should be 3 mentions associated with each post
     $this->assertEqual(sizeof($res1), 3);
     $this->assertEqual(sizeof($res2), 3);
     $this->assertEqual($res2[2]['mention_id'], 5);
     // for a given mention, there should be two posts
     $res3 = $this->dao->getMentionInfoUserName('joanwalsh');
     $this->assertEqual($res3['user_id'], 1106501);
     $this->assertEqual($res3['count_cache'], 2);
     $res4 = $this->dao->getMentionsForPostMID(3);
     $this->assertEqual(sizeof($res4), 2);
     $this->assertEqual($res4[0]['post_id'], '39089424620978176');
     $this->assertEqual($res4[1]['author_user_id'], 123457);
     // the duplicate mention for AntDeRosa should not have been counted
     $stmt = MentionMySQLDAO::$PDO->query('SELECT count_cache FROM ' . $this->table_prefix . 'mentions WHERE
     user_id = "1140451" AND network = "twitter"');
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $this->assertEqual(intval($row['count_cache']), 2);
 }
 public function testInsertMentions()
 {
     $mentions = array(array('user_id' => 136881432, 'user_name' => 'HeyJacquiDey'), array('user_id' => 1106501, 'user_name' => 'joanwalsh'), array('user_id' => 1140451, 'user_name' => 'AntDeRosa'));
     $this->dao->insertMentions($mentions, '39089424620978176', 123456, 'twitter');
     $this->dao->insertMentions($mentions, '39089424620978177', 123457, 'twitter');
     $res1 = $this->dao->getMentionsForPost('39089424620978176');
     $res2 = $this->dao->getMentionsForPost('39089424620978177');
     // there should be 3 mentions associated with each post
     $this->assertEqual(sizeof($res1), 3);
     $this->assertEqual(sizeof($res2), 3);
     $this->assertEqual($res2[2]['mention_id'], 5);
     // for a given mention, there should be two posts
     $res3 = $this->dao->getMentionInfoUserName('joanwalsh');
     $this->assertEqual($res3['user_id'], 1106501);
     $this->assertEqual($res3['count_cache'], 2);
     $res4 = $this->dao->getMentionsForPostMID(3);
     $this->assertEqual(sizeof($res4), 2);
     $this->assertEqual($res4[0]['post_id'], '39089424620978176');
     $this->assertEqual($res4[1]['author_user_id'], 123457);
 }
Ejemplo n.º 3
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');
     $h_dao = new HashTagMySQLDAO();
     $m_dao = new MentionMySQLDAO();
     $h = $h_dao->getHashtagInfoForTag('Clinton');
     $this->assertEqual($h['count_cache'], 2);
     $hp = $h_dao->getHashtagsForPost('39088587140108288');
     $this->assertEqual(sizeof($hp), 1);
     $this->assertEqual($hp[0]['post_id'], '39088587140108288');
     $hp = $h_dao->getHashtagsForPost('39089424620978176');
     $this->assertEqual($hp[0]['post_id'], '39089424620978176');
     $this->assertEqual($hp[0]['hashtag_id'], 1);
     $hph = $h_dao->getHashtagsForPostHID(1);
     $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');
 }