public function testGetThisYearOfPostsIterator() { $dao = new PostMySQLDAO(); $posts = $dao->getThisYearOfPostsIterator(18, 'twitter'); $this->assertIsA($posts, 'PostIterator'); $cnt = 0; foreach ($posts as $key => $value) { $cnt++; } $this->assertEqual(0, $cnt); $counter = 99999; $this->builders[] = FixtureBuilder::build('posts', array('id' => $counter, 'post_id' => $counter, 'author_user_id' => '18', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'pub_date' => date('Y-m-d h:i:s', strtotime('-1 day')), 'reply_count_cache' => $counter == 10 ? 0 : rand(0, 4), 'is_protected' => 0, 'retweet_count_cache' => floor($counter / 2), 'network' => 'twitter', 'in_reply_to_user_id' => null, 'old_retweet_count_cache' => floor($counter / 3), 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0)); $posts = $dao->getThisYearOfPostsIterator(18, 'twitter'); $this->assertIsA($posts, 'PostIterator'); $cnt = 0; foreach ($posts as $key => $value) { $cnt++; } $this->assertEqual(1, $cnt); $counter++; $this->builders[] = FixtureBuilder::build('posts', array('id' => $counter, 'post_id' => $counter, 'author_user_id' => '18', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'pub_date' => date('Y-m-d h:i:s', strtotime('-2 day')), 'reply_count_cache' => $counter == 10 ? 0 : rand(0, 4), 'is_protected' => 0, 'retweet_count_cache' => floor($counter / 2), 'network' => 'twitter', 'in_reply_to_user_id' => null, 'old_retweet_count_cache' => floor($counter / 3), 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0)); $posts = $dao->getThisYearOfPostsIterator(18, 'twitter'); $cnt = 0; foreach ($posts as $key => $value) { $cnt++; } $this->assertEqual(2, $cnt); $counter++; $this->builders[] = FixtureBuilder::build('posts', array('id' => $counter, 'post_id' => $counter, 'author_user_id' => '18', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'pub_date' => date('Y-m-d h:i:s', strtotime('-400 day')), 'reply_count_cache' => $counter == 10 ? 0 : rand(0, 4), 'is_protected' => 0, 'retweet_count_cache' => floor($counter / 2), 'network' => 'twitter', 'in_reply_to_user_id' => null, 'old_retweet_count_cache' => floor($counter / 3), 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0)); $posts = $dao->getThisYearOfPostsIterator(18, 'twitter'); $cnt = 0; foreach ($posts as $key => $value) { $cnt++; } $this->assertEqual(2, $cnt); $yearday = date('z'); $counter++; $this->builders[] = FixtureBuilder::build('posts', array('id' => $counter, 'post_id' => $counter, 'author_user_id' => '18', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'pub_date' => date('Y-m-d h:i:s', strtotime('-' . ($yearday + 1) . ' day')), 'reply_count_cache' => $counter == 10 ? 0 : rand(0, 4), 'is_protected' => 0, 'retweet_count_cache' => floor($counter / 2), 'network' => 'twitter', 'in_reply_to_user_id' => null, 'old_retweet_count_cache' => floor($counter / 3), 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0)); $posts = $dao->getThisYearOfPostsIterator(18, 'twitter'); $cnt = 0; foreach ($posts as $key => $value) { $cnt++; } $this->assertEqual(2, $cnt); $counter++; $this->builders[] = FixtureBuilder::build('posts', array('id' => $counter, 'post_id' => $counter, 'author_user_id' => '18', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'pub_date' => date('Y-m-d h:i:s', strtotime('-' . $yearday . ' day')), 'reply_count_cache' => $counter == 10 ? 0 : rand(0, 4), 'is_protected' => 0, 'retweet_count_cache' => floor($counter / 2), 'network' => 'twitter', 'in_reply_to_user_id' => null, 'old_retweet_count_cache' => floor($counter / 3), 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0)); $posts = $dao->getThisYearOfPostsIterator(18, 'twitter'); $cnt = 0; foreach ($posts as $key => $value) { $cnt++; } $this->assertEqual(3, $cnt); }