public function testLinkUtilities()
 {
     $year = date('Y');
     $user_id = $this->instance->network_user_id;
     $counter = 12;
     $days = 0;
     // set up most links
     while ($counter != 0) {
         $post_key = $counter + 1760;
         $days++;
         $builders[] = FixtureBuilder::build('posts', array('id' => $post_key, 'post_id' => $post_key, 'network' => 'twitter', 'author_user_id' => $user_id, 'author_username' => 'user', 'in_reply_to_user_id' => NULL, 'in_retweet_of_post_id' => NULL, 'retweet_count_cache' => $days, 'reply_count_cache' => $days, 'favlike_count_cache' => $days, 'in_reply_to_post_id' => 0, 'is_protected' => 0, 'author_fullname' => 'User', 'post_text' => 'Link post http://lifehacker.com/' . $counter, 'pub_date' => '-1d'));
         $builders[] = FixtureBuilder::build('links', array('url' => 'http://lifehacker.com/' . $counter, 'title' => 'Link ' . $counter, 'post_key' => $post_key, 'expanded_url' => 'http://lifehacker.com/' . $counter, 'error' => '', 'image_src' => ''));
         $counter--;
     }
     // set up fewer links
     $counter = 10;
     $days = 0;
     while ($counter != 0) {
         $post_key = $counter + 1860;
         $days++;
         $builders[] = FixtureBuilder::build('posts', array('id' => $post_key, 'post_id' => $post_key, 'network' => 'twitter', 'author_user_id' => $user_id, 'author_username' => 'user', 'in_reply_to_user_id' => NULL, 'in_retweet_of_post_id' => NULL, 'in_reply_to_post_id' => 0, 'is_protected' => 0, 'author_fullname' => 'User', 'post_text' => 'Link post http://nytimes.com/' . $counter, 'pub_date' => '-1d'));
         $builders[] = FixtureBuilder::build('links', array('url' => 'http://nytimes.com/' . $counter, 'title' => 'Link ' . $counter, 'post_key' => $post_key, 'expanded_url' => 'http://nytimes.com/' . $counter, 'error' => '', 'image_src' => ''));
         $counter--;
     }
     $insight_plugin = new EOYMostLinksInsight();
     $post_dao = new PostMySQLDAO();
     $it_posts = $post_dao->getThisYearOfPostsWithLinksIterator($author_id = $this->instance->network_user_id, $network = $this->instance->network);
     $posts = array();
     foreach ($it_posts as $post) {
         $posts[] = $post;
     }
     $this->assertEqual(count($posts), 22);
     $domain_counts = $insight_plugin->getDomainCounts($posts);
     $this->debug(Utils::varDumpToString($domain_counts));
     $sorted_domains = array(0 => array('lifehacker.com' => 12), 1 => array('nytimes.com' => 10));
     $i = 0;
     foreach ($domain_counts as $domain => $count) {
         $this->assertEqual($sorted_domains[$i][$domain], $count);
         $i++;
     }
     $domain = $insight_plugin->getPopularDomain($domain_counts);
     $this->assertEqual('lifehacker.com', $domain);
     $posts = $insight_plugin->getMostPopularPostsLinkingTo($this->instance, $domain);
     $this->debug(Utils::varDumpToString($posts));
     $this->assertEqual(3, count($posts));
     $this->assertEqual($posts[0]->id, 1761);
     $this->assertEqual($posts[2]->id, 1763);
 }