public function testAlternateHeadline()
 {
     TimeHelper::setTime(3);
     // Get data ready that insight requires
     $builders = self::buildData();
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_user_id = 7612345;
     $instance->network_username = '******';
     $instance->network = 'twitter';
     $insight_plugin = new FavoritedLinksInsight();
     $insight_plugin->generateInsight($instance, null, $last_week_of_posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('favorited_links', 10, $today);
     $fav_posts = unserialize($result->related_data);
     $this->assertNotNull($result);
     $this->assertEqual('1 link @testeriffic liked', $result->headline);
     $this->assertEqual(count($fav_posts), 1);
     $this->debug($this->getRenderedInsightInHTML($result));
     $this->debug($this->getRenderedInsightInEmail($result));
     $builders[] = FixtureBuilder::build('posts', array('id' => 999, 'post_id' => 999, 'author_user_id' => 7654321, 'author_username' => 'twitteruser', 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => 'twitter', 'post_text' => 'This is an old post http://t.co/aMHh5XHGfS with a link.', 'source' => 'web', 'pub_date' => $yesterday, 'reply_count_cache' => 0, 'is_protected' => 0));
     $builders[] = FixtureBuilder::build('links', array('post_key' => 999, 'url' => 'http://t.co/aMHh5XHGfS', 'expanded_url' => 'http://techcrunch.com/2013/04/28/disrupt-ny-hackathon-gets-hacked-man-' . 'takes-stage-and-uses-his-60-seconds-to-disrupt-capitalism/'));
     $builders[] = FixtureBuilder::build('favorites', array('post_id' => 999, 'author_user_id' => 7654321, 'fav_of_user_id' => 7612345, 'network' => 'twitter', 'fav_timestamp' => $today));
     $insight_plugin->generateInsight($instance, null, $last_week_of_posts, 3);
     $result = $insight_dao->getInsight('favorited_links', 10, $today);
     $fav_posts = unserialize($result->related_data);
     $this->assertNotNull($result);
     $this->assertEqual('2 links @testeriffic liked', $result->headline);
     $this->assertEqual(count($fav_posts), 1);
     $this->debug($this->getRenderedInsightInHTML($result));
     $this->debug($this->getRenderedInsightInEmail($result));
 }
Пример #2
0
 public function testFavoritedLinksInsightForGooglePlusNoFavoritedLinks()
 {
     // Get data ready that insight requires
     $builders = self::buildData();
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_user_id = 7612345;
     $instance->network_username = '******';
     $instance->network = 'google+';
     $insight_plugin = new FavoritedLinksInsight();
     $insight_plugin->generateInsight($instance, $last_week_of_posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('favorited_links', 10, $today);
     $this->assertNull($result);
 }