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); }