예제 #1
0
 public function testGetAverageReplyCount()
 {
     $builders = array();
     //Add straight text posts
     $counter = 1;
     while ($counter < 40) {
         $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT);
         if ($counter % 3 == 0) {
             $source = '<a href="http://twitter.com" rel="nofollow">Tweetie for Mac</a>';
         } else {
             if ($counter % 3 == 1) {
                 $source = '<a href="http://twitter.com/tweetbutton" rel="nofollow">Tweet Button</a>';
             } else {
                 $source = 'web';
             }
         }
         $builders[] = FixtureBuilder::build('posts', array('id' => $counter + 256, 'post_id' => $counter + 256, 'author_user_id' => '13', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'source' => $source, 'pub_date' => '-' . $counter . 'd', 'in_reply_to_user_id' => null, 'reply_count_cache' => $counter, 'is_protected' => 0, 'retweet_count_cache' => 0, 'network' => 'twitter', 'favlike_count_cache' => 0, 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0));
         $counter++;
     }
     $dao = new PostMySQLDAO();
     //without date (today)
     $average_reply_count = $dao->getAverageReplyCount('ev', 'twitter', 7);
     $this->assertEqual($average_reply_count, 4);
     //yesterday
     $average_reply_count = $dao->getAverageReplyCount('ev', 'twitter', 7, date("Y-m-d", strtotime("-1 day")));
     $this->assertEqual($average_reply_count, 5);
     //40 days ago
     $average_reply_count = $dao->getAverageReplyCount('ev', 'twitter', 7, date("Y-m-d", strtotime("-40 day")));
     $this->assertEqual($average_reply_count, 20);
 }