Example #1
0
 /**
  * Test getMostRepliedToPostsByPublicInstancesInLastWeek
  */
 function testGetMostRepliedToPostsByPublicInstancesInLastWeek()
 {
     //Add posts with retweets by user3, who is on the public timeline with retweet counts in the last 9 days
     $counter = 0;
     $id = 200;
     while ($counter < 40) {
         $id += $counter;
         $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$id}, 23, 'user3', 'User 3', 'avatar.jpg', 'This is post with {$counter} replies', 'web', DATE_SUB(NOW(), INTERVAL " . $counter . " DAY), " . $counter . ", 0 );";
         //echo $q;
         PDODAO::$PDO->exec($q);
         $counter++;
     }
     $pdao = new PostMySQLDAO();
     $page1ofposts = $pdao->getMostRepliedToPostsByPublicInstancesInLastWeek(1, 5);
     $this->assertEqual(sizeof($page1ofposts), 5);
     $this->assertEqual($page1ofposts[0]->mention_count_cache, 7);
     $this->assertEqual($page1ofposts[1]->mention_count_cache, 6);
     $page2ofposts = $pdao->getMostRepliedToPostsByPublicInstancesInLastWeek(2, 5);
     $this->assertEqual(sizeof($page2ofposts), 2);
     $this->assertEqual($page2ofposts[0]->mention_count_cache, 2);
     $this->assertEqual($page2ofposts[1]->mention_count_cache, 1);
     $totals = $pdao->getTotalPagesAndPostsByPublicInstances(5, 7);
     $this->assertEqual($totals["total_posts"], 7);
     $this->assertEqual($totals["total_pages"], 2);
 }