コード例 #1
0
 public function testGetFavoritesFromOneYearAgo()
 {
     //build post published one year ago today
     $builders[] = FixtureBuilder::build('posts', array('post_id' => 'abadadfd1212', 'author_user_id' => '19', 'author_username' => 'linkbaiter', 'author_fullname' => 'Link Baiter', 'is_geo_encoded' => 0, 'post_text' => 'This is link post ' . $counter, 'source' => 'web', 'pub_date' => '-365d', 'reply_count_cache' => 0, 'retweet_count_cache' => 0, 'network' => 'twitter', 'is_protected' => 0));
     //build favorite of that post by test user ev
     $builders[] = FixtureBuilder::build('favorites', array('post_id' => 'abadadfd1212', 'author_user_id' => '19', 'fav_of_user_id' => '13', 'network' => 'twitter'));
     //get favorites from one year ago today
     $result = $this->dao->getFavoritesFromOneYearAgo('13', 'twitter');
     //assert post is returned
     $this->assertEqual(sizeof($result), 1);
     $this->assertEqual($result[0]->post_id, 'abadadfd1212');
     //build post published one year and 4 days ago today
     $builders[] = FixtureBuilder::build('posts', array('post_id' => 'abadadfd1213', 'author_user_id' => '19', 'author_username' => 'linkbaiter', 'author_fullname' => 'Link Baiter', 'is_geo_encoded' => 0, 'post_text' => 'This is link post ' . $counter, 'source' => 'web', 'pub_date' => '-369d', 'reply_count_cache' => 0, 'retweet_count_cache' => 0, 'network' => 'twitter', 'is_protected' => 0));
     //build favorite of that post by test user ev
     $builders[] = FixtureBuilder::build('favorites', array('post_id' => 'abadadfd1213', 'author_user_id' => '19', 'fav_of_user_id' => '13', 'network' => 'twitter'));
     $since_date = date("Y-m-d", strtotime("-4 day"));
     //get favorites from one year ago today
     $result = $this->dao->getFavoritesFromOneYearAgo('13', 'twitter', $since_date);
     //assert post is returned
     $this->assertEqual(sizeof($result), 1);
     $this->assertEqual($result[0]->post_id, 'abadadfd1213');
 }