/**
  * Test getMostRetweetedPosts
  */
 public function testGetMostRetweetedPosts()
 {
     $dao = new PostMySQLDAO();
     $posts = $dao->getMostRetweetedPosts(13, 'twitter', 10);
     // track the sum of retweet_count_cache and old_retweet_count_cache, which is the criteria
     // by which this query should have been sorted.
     // flip the logic in this first test clause as per issue #813.
     $prev_count = $posts[0]->retweet_count_cache + $posts[0]->old_retweet_count_cache;
     foreach ($posts as $post) {
         $this->assertTrue($post->retweet_count_cache + $post->old_retweet_count_cache <= $prev_count);
         $prev_count = $post->retweet_count_cache + $post->old_retweet_count_cache;
     }
     // test paging
     $posts = $dao->getMostRetweetedPosts(13, 'twitter', $count = 1, $page = 1);
     $prev_count = $posts[0]->retweet_count_cache + $posts[0]->old_retweet_count_cache;
     for ($i = 2; $i <= 10; $i++) {
         $posts = $dao->getMostRetweetedPosts(13, 'twitter', $count = 1, $page = $i);
         $this->assertTrue($posts[0]->retweet_count_cache + $posts[0]->old_retweet_count_cache <= $prev_count);
         $prev_count = $posts[0]->retweet_count_cache + $posts[0]->old_retweet_count_cache;
     }
     // test count
     for ($i = 2; $i <= 10; $i++) {
         $posts = $dao->getMostRetweetedPosts(13, 'twitter', $count = $i, $page = 1);
         $this->assertTrue(count($posts) == $i);
     }
 }
 /**
  * Test getMostRetweetedPosts
  */
 public function testGetMostRetweetedPosts()
 {
     $dao = new PostMySQLDAO();
     $posts = $dao->getMostRetweetedPosts(13, 'twitter', 10);
     $prev_count = $posts[0]->retweet_count_cache;
     foreach ($posts as $post) {
         $this->assertTrue($post->retweet_count_cache >= $prev_count, "previous count " . $prev_count . " should be less than or equal to this post's count of " . $post->retweet_count_cache);
         $prev_count = $post->reply_count_cache;
     }
 }