本文整理汇总了PHP中InsightMySQLDAO类的典型用法代码示例。如果您正苦于以下问题:PHP InsightMySQLDAO类的具体用法?PHP InsightMySQLDAO怎么用?PHP InsightMySQLDAO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InsightMySQLDAO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLongLostContactsInsight
public function testLongLostContactsInsight()
{
// Get data ready that insight requires
$builders = self::buildData();
$instance = new Instance();
$instance->id = 10;
$instance->network_user_id = 7612345;
$instance->network_username = 'twitteruser';
$instance->network = 'twitter';
$insight_plugin = new LongLostContactsInsight();
$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('long_lost_contacts', 10, $today);
$contacts = unserialize($result->related_data);
$this->debug(Utils::varDumpToString($result));
$this->assertNotNull($result);
$this->assertIsA($result, "Insight");
$this->assertPattern('/\\@twitteruser hasn\'t replied to /', $result->text);
$this->assertPattern('/<strong>2 contacts<\\/strong> /', $result->text);
$this->assertPattern('/in over a year: /', $result->text);
$this->assertNoPattern('/a contact/', $result->text);
$this->assertIsA($contacts, "array");
$this->assertIsA($contacts[0], "User");
$this->assertEqual(count($contacts), 2);
}
示例2: test7DayClickHigh
public function test7DayClickHigh()
{
// Assert that insight doesn't exist
$insight_dao = new InsightMySQLDAO();
$yesterday = date('Y-m-d', strtotime('-1 day'));
$result = $insight_dao->getInsight('click_high_7_day_28', 1, $yesterday);
$this->assertNull($result);
$builders = self::buildData();
// Add post with a link that has lots of clicks
$post1_builder = FixtureBuilder::build('posts', array('id' => 28, 'post_id' => '28', 'author_user_id' => '13', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post 28', 'source' => 'web', 'pub_date' => '-1d', 'reply_count_cache' => 0, 'is_protected' => 0, 'retweet_count_cache' => 0, 'network' => 'twitter', 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0));
$link1_builder = FixtureBuilder::build('links', array('id' => 28, 'post_key' => '28', 'short_url' => 'http://bit.ly/blah', 'expanded_url' => 'http://expandedurl.com/asfasdfadsf/adsfa'));
$builders[] = FixtureBuilder::build('links_short', array('id' => 28, 'link_id' => '28', 'short_url' => 'http://bit.ly/blah' . $counter, 'click_count' => 7609));
$builders[] = FixtureBuilder::build('insights', array('slug' => 'ShortLinkMySQLDAO::getRecentClickStats', 'date' => $yesterday, 'instance_id' => 1, 'related_data' => serialize('sample click spike data')));
// Get data ready that insight requires
$post1_object = new Post($post1_builder->columns);
$link1_object = new Link($link1_builder->columns);
$post1_object->links = array($link1_object);
$posts = array();
$posts[] = $post1_object;
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = '13';
$instance->network = 'twitter';
$instance->network_username = 'ev';
$clickspike_insight_plugin = new ClickSpikeInsight();
$clickspike_insight_plugin->generateInsight($instance, null, $posts, 3);
//sleep(1000);
// Assert that insight got generated
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('click_high_7_day_28', 1, $yesterday);
$this->assertNotNull($result);
$this->assertEqual($result->slug, 'click_high_7_day_28');
$this->assertEqual($result->filename, 'clickspike');
$this->assertPattern('/Viewers clicked \\@ev\'s link \\<strong\\>7,609 times\\<\\/strong\\>/', $result->headline);
}
示例3: testStyleStats
public function testStyleStats()
{
// Assert that insight doesn't exist
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('style_stats', 1, date('Y-m-d'));
$this->assertNull($result);
$builders = self::buildData();
// Add post that's not a photo, link, quotation, or question
$post1_builder = FixtureBuilder::build('posts', array('id' => 28, 'post_id' => '28', 'author_user_id' => '13', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post 28', 'source' => 'web', 'pub_date' => '-1d', 'reply_count_cache' => 0, 'is_protected' => 0, 'retweet_count_cache' => 0, 'network' => 'twitter', 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0));
$link1_builder = FixtureBuilder::build('links', array('id' => 28, 'post_key' => '28', 'short_url' => 'http://bit.ly/blah', 'expanded_url' => 'http://expandedurl.com/asfasdfadsf/adsfa'));
$builders[] = FixtureBuilder::build('links_short', array('id' => 28, 'link_id' => '28', 'short_url' => 'http://bit.ly/blah' . $counter, 'click_count' => 7609));
$builders[] = FixtureBuilder::build('insights', array('slug' => 'PostMySQLDAO::getHotPosts', 'date' => date('Y-m-d'), 'instance_id' => 1));
// Add a question
$post2_builder = FixtureBuilder::build('posts', array('id' => 29, 'post_id' => '29', 'author_user_id' => '13', 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'author_avatar' => 'avatar.jpg', 'post_text' => 'Is this post 29?', 'source' => 'web', 'pub_date' => '-1d', 'reply_count_cache' => 0, 'is_protected' => 0, 'retweet_count_cache' => 0, 'network' => 'twitter', 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_retweet_of_post_id' => null, 'is_geo_encoded' => 0));
$post_dao = new PostMySQLDAO();
$last_week_of_posts = $post_dao->getAllPostsByUsernameOrderedBy('ev', 'twitter', $count = 0, $order_by = "pub_date", $in_last_x_days = 7, $iterator = false, $is_public = false);
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = '13';
$instance->network = 'twitter';
$instance->network_username = 'ev';
$stylestats_insight_plugin = new StyleStatsInsight();
$stylestats_insight_plugin->generateInsight($instance, null, $last_week_of_posts, 3);
// Assert that insight got generated
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('style_stats', 1, date('Y-m-d'));
$this->assertNotNull($result);
$this->assertEqual($result->slug, 'style_stats');
$this->assertEqual($result->filename, 'stylestats');
$this->assertEqual("7 of @ev's posts this week were photos and 1 was a question", $result->headline);
//sleep(1000);
}
示例4: testHelloThinkUpInsight
public function testHelloThinkUpInsight()
{
$posts = array();
$instance = new Instance();
$hello_thinkup_insight_plugin = new HelloThinkUpInsight();
$hello_thinkup_insight_plugin->generateInsight($instance, $posts, 3);
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('my_test_insight_hello_thinkup', 1, '2013-12-21');
$this->assertEqual($result->headline, 'Ohai');
$this->assertEqual($result->text, 'Greetings humans');
$this->assertEqual($result->filename, 'hellothinkupinsight');
$this->assertNull($result->related_data);
$this->assertEqual($result->emphasis, Insight::EMPHASIS_MED);
}
示例5: testSavedSearchResults
public function testSavedSearchResults()
{
// Assert that insight doesn't exist
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('saved_search_results_102', 1, date('Y-m-d'));
$this->assertNull($result);
$builders = self::buildData();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = '13';
$instance->network = 'facebook';
$instance->network_username = 'ev';
$stylestats_insight_plugin = new SavedSearchResultsInsight();
$stylestats_insight_plugin->generateInsight($instance, null, $last_week_of_posts, 3);
// Assert that insight got generated
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('saved_search_results_102', 1, date('Y-m-d'));
$this->assertNotNull($result);
$this->assertEqual($result->slug, 'saved_search_results_102');
$this->assertEqual($result->filename, 'savedsearchresults');
$this->assertEqual('7 new posts contain "<strong>#thinkupsavedsearch</strong>".', $result->headline);
}
示例6: testWordInWord
public function testWordInWord()
{
$year = date('Y');
$builders = array();
$builders[] = FixtureBuilder::build('posts', array('pub_date' => $year . '-02-26', 'post_id' => 1, 'author_username' => $this->instance->network_username, 'author_user_id' => $this->instance->network_user_id, 'network' => $this->instance->network, 'post_text' => 'Radarthoughts is not a real word.'));
$post->author_username = $this->instance->network_username;
$post->author_user_id = $this->instance->network_user_id;
$insight_plugin = new StarWarsInsight();
$insight_dao = new InsightMySQLDAO();
$insight_plugin->generateInsight($this->instance, new User(), array($post), 3);
$result = $insight_dao->getInsight($insight_plugin->slug, $this->instance->id, date('Y-m-d'));
$this->assertNull($result);
}
示例7: testSavedSearchResults
public function testSavedSearchResults()
{
// Assert that insight doesn't exist
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('saved_search_results_102', 1, date('Y-m-d'));
$this->assertNull($result);
$builders = self::buildData();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = '13';
$instance->network = 'facebook';
$instance->network_username = 'ev';
$stylestats_insight_plugin = new SavedSearchResultsInsight();
$stylestats_insight_plugin->generateInsight($instance, $last_week_of_posts, 3);
// Assert that insight got generated
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('saved_search_results_102', 1, date('Y-m-d'));
$this->assertNotNull($result);
$this->assertEqual($result->slug, 'saved_search_results_102');
$this->assertEqual($result->headline, 'New search results:');
$this->assertEqual($result->filename, 'savedsearchresults');
$this->assertEqual('7 new posts contain <b><a href="search.php?u=ev&n=facebook&c=searches&k=%23' . 'thinkupsavedsearch&q=%23thinkupsavedsearch">#thinkupsavedsearch</a></b>.', $result->text);
}
示例8: testNormalFacebookIncompleteData
public function testNormalFacebookIncompleteData()
{
$this->instance = new Instance();
$this->instance->id = 1;
$this->instance->network_username = 'fbuser1';
$this->instance->network_user_id = '30';
$this->instance->network = 'facebook';
$builders = self::buildTruckloadOfFacebookData();
//User fixtures set up in buildTruckloadOfFacebookData
/*
$ub1 = FixtureBuilder::build('users', array('user_id'=>30, 'user_name'=>'fbuser1',
'full_name'=>'Facebook User 1', 'is_protected'=>0, 'network'=>'facebook'));
array_push($builders, $ub1);
$ub2 = FixtureBuilder::build('users', array('user_id'=>31, 'user_name'=>'fbuser2',
'full_name'=>'Facebook User 2', 'is_protected'=>0, 'network'=>'facebook'));
array_push($builders, $ub2);
$ub3 = FixtureBuilder::build('users', array('user_id'=>32, 'user_name'=>'fbuser3',
'full_name'=>'Facebook User 3', 'is_protected'=>0, 'network'=>'facebook'));
array_push($builders, $ub3);
*/
//Add replies to friends
$counter = 1;
while ($counter < 10) {
if ($counter % 2 == 1) {
$in_reply_to_user_id = 31;
//fbuser2
} else {
$in_reply_to_user_id = 32;
//fbuser3
}
$builders[] = FixtureBuilder::build('posts', array('post_id' => $counter + 34358, 'author_user_id' => '30', 'author_username' => 'fbuser1', 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'source' => $source, 'pub_date' => '-12d' . $pseudo_minute . ':00', 'reply_count_cache' => $counter == 10 ? 0 : rand(0, 4), 'is_protected' => 0, 'retweet_count_cache' => floor($counter / 2), 'network' => 'facebook', 'in_reply_to_user_id' => $in_reply_to_user_id, '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));
$counter++;
}
//Add replies from friends
$counter = 1;
while ($counter < 10) {
if ($counter % 2 == 1) {
$author_user_id = 31;
$author_username = 'fbuser2';
} else {
$author_user_id = 32;
$author_username = 'fbuser3';
}
$builders[] = FixtureBuilder::build('posts', array('post_id' => $counter + 5467, 'author_user_id' => $author_user_id, 'author_username' => $author_username, 'author_avatar' => 'avatar.jpg', 'post_text' => 'This is post ' . $counter, 'source' => $source, 'pub_date' => '-15d' . $pseudo_minute . ':00', 'reply_count_cache' => $counter == 10 ? 0 : rand(0, 4), 'is_protected' => 0, 'retweet_count_cache' => floor($counter / 2), 'network' => 'facebook', 'in_reply_to_user_id' => '30', '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));
$counter++;
}
$posts = array();
$insight_plugin = new EOYBestieInsight();
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
// Assert that insight got inserted
$insight_dao = new InsightMySQLDAO();
$year = date('Y');
$result = $insight_dao->getInsight($insight_plugin->slug, $this->instance->id, $year . '-' . $insight_plugin->run_date);
$this->assertNotNull($result);
$this->assertIsA($result, "Insight");
$this->assertEqual("fbuser1's Facebook bestie of 2015", $result->headline);
$this->assertEqual("Everyone loves getting comments from their friends. In 2015, fbuser2 commented on " . "fbuser1's status updates <strong>5 times</strong>, more than anyone else (at least since November). " . "Best friends forever!", $result->text);
$this->dumpRenderedInsight($result, $this->instance, "No bestie incomplete data, Twitter");
}
示例9: testDoesInsightExist
public function testDoesInsightExist()
{
$dao = new InsightMySQLDAO();
$result = $dao->doesInsightExist("avg_replies_per_week", 1);
$this->assertTrue($result);
$result = $dao->doesInsightExist("avg_replies_per_week", 10);
$this->assertFalse($result);
$result = $dao->doesInsightExist("yo_yo_yooo", 1);
$this->assertFalse($result);
}
示例10: testTimeGeneratedDoesntUpdate
public function testTimeGeneratedDoesntUpdate()
{
$today = date('Y-m-d');
$baseline_dao = DAOFactory::getDAO('InsightBaselineDAO');
foreach (array('fave', 'reply', 'retweet') as $act) {
$baseline_dao->insertInsightBaseline("avg_{$act}_count_last_7_days", $this->instance->id, 2, $today);
$baseline_dao->insertInsightBaseline("high_{$act}_count_last_7_days", $this->instance->id, 2, $today);
}
// We add an old baseline so that 7 day checks
$baseline_dao->insertInsightBaseline('high_fave_count_last_365_days', $this->instance->id, $avg = 2, date('Y-m-d', time() - 8 * 24 * 60 * 60));
$posts = array($this->makePost($replies = 1, $retweets = 10, $faves = 50));
$insight_plugin = new ActivitySpikeInsight();
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$insight_dao = new InsightMySQLDAO();
$result = $insight_dao->getInsight('fave_high_7_day_1', 10, $today);
$this->assertNotNull($result);
$this->assertEqual('@buffy really got some likes', $result->headline);
$generated = $result->time_generated;
$date = $result->date;
sleep(1);
// force timestamp to change
$posts = array($this->makePost($replies = 1, $retweets = 10, $faves = 100));
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight('fave_high_7_day_1', 10, $today);
$this->assertNotNull($result);
$this->assertEqual('@buffy really got some likes', $result->headline);
$this->assertEqual($result->time_generated, $generated);
$this->assertEqual($result->date, $date);
}
示例11: testSingleLongLostContact
public function testSingleLongLostContact()
{
// Get data ready that insight requires
$builders = self::buildData($multiple = false);
$instance = new Instance();
$instance->id = 10;
$instance->network_user_id = 7612345;
$instance->network_username = 'twitteruser';
$instance->network = 'twitter';
$insight_plugin = new LongLostContactsInsight();
$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('long_lost_contacts', 10, $today);
$contacts = unserialize($result->related_data);
$this->debug(Utils::varDumpToString($result));
$this->assertNotNull($result);
$this->assertIsA($result, "Insight");
$this->assertPattern('/\\@twitteruser hasn\'t replied to /', $result->headline);
$this->assertPattern('/Twitter Follower One /', $result->headline);
$this->assertPattern('/in over a year/', $result->headline);
$this->assertPattern('/avatar.jpg/', $result->header_image);
$this->assertNoPattern('/people/', $result->headline);
$this->assertIsA($contacts, "array");
$this->assertIsA($contacts["people"][0], "User");
$this->assertEqual(count($contacts["people"]), 1);
$this->debug($this->getRenderedInsightInHTML($result));
$this->debug($this->getRenderedInsightInEmail($result));
}
示例12: testAlternateHeadline
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 = 'testeriffic';
$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));
}
示例13: testInsightTextsFacebook
public function testInsightTextsFacebook()
{
$instance = new Instance();
$instance->id = 10;
$instance->network_username = 'Jo ThinkUp';
$instance->network = 'facebook';
$insight_dao = new InsightMySQLDAO();
$today = date('Y-m-d');
$insight_plugin = new WeeklyGraphInsight();
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 0, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 0, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 0, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 0, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
TimeHelper::setTime(1);
//set headline to expect
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('weekly_graph', 10, $today);
$this->assertEqual("Jo ThinkUp really inspired conversations", $result->headline);
$this->assertEqual('In the past week, comments to Jo ThinkUp outnumbered likes or reshares.', $result->text);
$this->dumpRenderedInsight($result, $instance, "");
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
TimeHelper::setTime(2);
//set headline to expect
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('weekly_graph', 10, $today);
$this->assertEqual("Jo ThinkUp shared lots of things people wanted to amplify", $result->headline);
$this->assertEqual("This past week, Jo ThinkUp's reshares outnumbered comments by 12 and likes by 12.", $result->text);
$this->dumpRenderedInsight($result, $instance, "");
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 0, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
TimeHelper::setTime(3);
//set headline to expect
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('weekly_graph', 10, $today);
$this->assertEqual("Jo ThinkUp really inspired conversations", $result->headline);
$this->assertEqual('In the past week, comments to Jo ThinkUp outnumbered likes.', $result->text);
$this->dumpRenderedInsight($result, $instance, "");
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 3, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
TimeHelper::setTime(4);
//set headline to expect
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('weekly_graph', 10, $today);
$this->assertEqual("Jo ThinkUp really inspired conversations", $result->headline);
$this->assertEqual('Jo ThinkUp got more comments than anything else.', $result->text);
$this->dumpRenderedInsight($result, $instance, "");
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
TimeHelper::setTime(5);
//set headline to expect
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('weekly_graph', 10, $today);
$this->assertEqual("Whatever Jo ThinkUp said must have been memorable", $result->headline);
$this->assertEqual('In the past week, Jo ThinkUp got 12 likes, beating out 8 reshares.', $result->text);
$this->dumpRenderedInsight($result, $instance, "");
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 3, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('weekly_graph', 10, $today);
$this->assertEqual("Whatever Jo ThinkUp said must have been memorable", $result->headline);
$this->assertEqual('In the past week, Jo ThinkUp got 12 likes.', $result->text);
$this->dumpRenderedInsight($result, $instance, "");
$posts = array();
$posts[] = new Post(array('reply_count_cache' => 1, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 1, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 1, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$posts[] = new Post(array('reply_count_cache' => 1, 'retweet_count_cache' => 2, 'favlike_count_cache' => 3, 'pub_date' => date('Y-m-d H:i:s', strtotime('-' . $days . ' day'))));
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('weekly_graph', 10, $today);
$this->assertEqual("Whatever Jo ThinkUp said must have been memorable", $result->headline);
$this->assertEqual('In the past week, Jo ThinkUp got 12 likes, beating out 4 comments and 8 reshares.', $result->text);
$this->dumpRenderedInsight($result, $instance, "");
}
示例14: testAllAboutYouInsightPriorEqualBaseline
public function testAllAboutYouInsightPriorEqualBaseline()
{
// Get data ready that insight requires
$posts = self::getTestPostObjects();
$instance = new Instance();
$instance->id = 10;
$instance->network_username = 'testeriffic';
$instance->network = 'twitter';
$insight_plugin = new AllAboutYouInsight();
// Add a baseline from prior week
$last_week = date('Y-m-d', strtotime('-7 day'));
$builder = FixtureBuilder::build('insight_baselines', array('date' => $last_week, 'slug' => 'all_about_you', 'instance_id' => 10, 'value' => 9));
$insight_plugin->generateInsight($instance, $posts, 3);
// Assert that week-over-week comparison is correct
$insight_dao = new InsightMySQLDAO();
$today = date('Y-m-d');
$result = $insight_dao->getInsight('all_about_you', 10, $today);
$this->debug(Utils::varDumpToString($result));
$this->assertNotNull($result);
$this->assertIsA($result, "Insight");
$this->assertPattern('/\\@testeriffic\'s posts contained the words/', $result->text);
$this->assertPattern('/9 times/', $result->text);
//assert no comparison to prior week
$this->assertNoPattern('/prior week/', $result->text);
$this->assertNoPattern('/prior week/', $result->text);
}
示例15: testLowDecrease
public function testLowDecrease()
{
$user = self::buildData();
// Insert a video that would have lowered the subscriber count by >= 50%
$post_builder = FixtureBuilder::build('posts', array('id' => 1, 'post_id' => '1', 'author_username' => 'ev', 'post_text' => 'My Great Video', 'pub_date' => '-1d', 'network' => 'youtube'));
$video_builder = FixtureBuilder::build('videos', array('id' => 1, 'post_key' => '1', 'subscribers_gained' => 0, 'subscribers_lost' => 4, 'average_view_percentage' => 10));
$instance = new Instance();
$instance->id = 1;
$instance->network = 'youtube';
$instance->network_username = 'ev';
$instance->network_user_id = 1;
$insight = new SubscriberChangeInsight();
$posts[] = new Post($post_builder->columns);
$insight->generateInsight($instance, $this->getUser(), $posts, 7);
// Assert that insight got inserted
$insight_dao = new InsightMySQLDAO();
$today = date('Y-m-d');
$result = $insight_dao->getInsight('subscriber_change1', 1, date('Y-m-d', strtotime('-1 day')));
$this->assertNotNull($result);
$this->assertIsA($result, "Insight");
$headline = "My Great Video decreased ev's subscriber count by <strong>16.67%</strong>.";
$this->assertEqual($result->headline, $headline);
$this->assertEqual($result->emphasis, 0);
}