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);
 }
 /**
  * This test checks 'old-style' rt handling and mentions
  */
 public function testAddPostOldStyleRTNoPostID()
 {
     list($post, $entities, $user_array) = $this->buildStreamPostArray3();
     $dao = new PostMySQLDAO();
     $user_dao = new UserMySQLDAO();
     $dao->addPostAndAssociatedInfo($post, $entities, $user_array);
     $post = $dao->getPost('39088041628934144', 'twitter');
     $this->assertEqual($post->in_rt_of_user_id, 40025121);
     $user = $user_dao->getDetails(140955302, 'twitter');
     $this->assertEqual($user->username, 'DAaronovitch');
     $m_dao = new MentionMySQLDAO();
     $mention = $m_dao->getMentionInfoUserID(40025121);
     $mp = $m_dao->getMentionsForPost('39088041628934144');
     $this->assertTrue($mention != null);
     $this->assertEqual($mention['user_name'], 'RSAMatthew');
     $this->assertEqual($mention['count_cache'], 1);
     $this->assertEqual($mp[0]['author_user_id'], 140955302);
 }