public function testWeeklyBestsInsightWithRepliesAndFavorites()
 {
     // Get data ready that insight requires
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_username = '******';
     $instance->network = 'twitter';
     $insight_builder = FixtureBuilder::build('insights', array('id' => 34, 'instance_id' => 10, 'slug' => 'PostMySQLDAO::getHotPosts', 'date' => '-1d'));
     $posts = array();
     $posts[] = new Post(array('reply_count_cache' => 4, 'retweet_count_cache' => 0, 'favlike_count_cache' => 5, 'pub_date' => date('Y-m-d H:i:s', strtotime('-1 day'))));
     // popularity_index = 30
     $insight_plugin = new WeeklyBestsInsight();
     $insight_plugin->generateInsight($instance, $posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('weekly_best', 10, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertPattern('/\\@testeriffic\'s most popular tweet from last week got /', $result->text);
     $this->assertPattern('/4 replies/', $result->text);
     $this->assertPattern('/5 favorites/', $result->text);
     $this->assertNoPattern('/,/', $result->text);
     $this->assertPattern('/and/', $result->text);
 }
 public function testWeeklyBestsInsightWithRepliesAndFavorites()
 {
     // Get data ready that insight requires
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_username = '******';
     $instance->network = 'twitter';
     $builders = self::setUpPublicInsight($instance);
     $posts = array();
     $posts[] = new Post(array('reply_count_cache' => 4, 'retweet_count_cache' => 0, 'favlike_count_cache' => 5, 'post_text' => 'This is a really good post', 'author_username' => $instance->network_username, 'author_user_id' => 'abc', 'author_avatar' => 'http://example.com/example.jpg', 'network' => $instance->network, 'pub_date' => date('Y-m-d H:i:s', strtotime('-1 day'))));
     // popularity_index = 30
     TimeHelper::setTime(1);
     $insight_plugin = new WeeklyBestsInsight();
     $insight_plugin->generateInsight($instance, null, $posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('weekly_best', 10, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertPattern('/\\@testeriffic\'s most popular tweet last week/', $result->headline);
     $this->assertPattern('/4 replies/', $result->text);
     $this->assertPattern('/5 favorites/', $result->text);
     $this->assertPattern('/and/', $result->text);
     /**
      * Use this code to output the individual insight's fully-rendered email HTML to file.
      * Then, open the file in your browser to view.
      *
      * $ TEST_DEBUG=1 php webapp/plugins/insightsgenerator/tests/TestOfHelloThinkUpInsight.php
      * -t testHelloThinkUpInsight > webapp/insight_email.html
      */
     $result->related_data = unserialize($result->related_data);
     $email_insight = $this->getRenderedInsightInEmail($result);
     //Uncomment this out to see the email view of insight
     $this->debug($email_insight);
     $this->debug($this->getRenderedInsightInHTML($result));
     $this->assertPattern('/This is a really good post/', $email_insight);
 }