当前位置: 首页>>代码示例>>PHP>>正文


PHP InsightMySQLDAO::getInsight方法代码示例

本文整理汇总了PHP中InsightMySQLDAO::getInsight方法的典型用法代码示例。如果您正苦于以下问题:PHP InsightMySQLDAO::getInsight方法的具体用法?PHP InsightMySQLDAO::getInsight怎么用?PHP InsightMySQLDAO::getInsight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InsightMySQLDAO的用法示例。


在下文中一共展示了InsightMySQLDAO::getInsight方法的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);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:27,代码来源:TestOfLongLostContactsInsight.php

示例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);
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:35,代码来源:TestOfClickSpikeInsight.php

示例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);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:32,代码来源:TestOfStyleStatsInsight.php

示例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);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:14,代码来源:TestOfHelloThinkUpInsight.php

示例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);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:22,代码来源:TestOfSavedSearchResultsInsight.php

示例6: 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);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:23,代码来源:TestOfSavedSearchResultsInsight.php

示例7: 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);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:29,代码来源:TestOfActivitySpikeInsight.php

示例8: 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));
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:30,代码来源:TestOfLongLostContactsInsight.php

示例9: 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));
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:34,代码来源:TestOfFavoritedLinksInsight.php

示例10: 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, "");
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:90,代码来源:TestOfWeeklyGraphInsight.php

示例11: 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);
 }
开发者ID:73sl4,项目名称:ThinkUp,代码行数:26,代码来源:TestOfAllAboutYouInsight.php

示例12: 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' => 'Radarscotusthoughts is not a real word.'));
     $post->author_username = $this->instance->network_username;
     $post->author_user_id = $this->instance->network_user_id;
     $insight_plugin = new LoveWinsInsight();
     $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);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:13,代码来源:TestOfLoveWinsInsight.php

示例13: 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");
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:61,代码来源:TestOfEOYBestieInsight.php

示例14: testFacebookNormalCase

 public function testFacebookNormalCase()
 {
     $this->instance->network_username = 'Mark Zuckerberg';
     $this->instance->network = 'facebook';
     $builders = self::setUpPublicInsight($this->instance);
     $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' => $this->instance->network, 'author_user_id' => $user_id, 'author_username' => 'Mark Zuckerberg', 'in_reply_to_user_id' => NULL, 'in_retweet_of_post_id' => NULL, 'in_reply_to_post_id' => 0, 'is_protected' => 0, 'author_fullname' => 'User', 'retweet_count_cache' => $days, 'reply_count_cache' => $days, 'favlike_count_cache' => $days, 'post_text' => 'Link post #' . $counter . ' http://lifehacker.com/' . $counter, 'pub_date' => '2015-10-01'));
         $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' => $this->instance->network, 'author_user_id' => $user_id, 'author_username' => 'Mark Zuckerberg', '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' => '2015-10-01'));
         $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--;
     }
     $posts = array();
     $insight_plugin = new EOYMostLinksInsight();
     $insight_plugin->generateInsight($this->instance, null, $posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $result = $insight_dao->getInsight('eoy_most_links', $this->instance->id, $year . '-' . $insight_plugin->run_date);
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $year = date('Y');
     $this->assertEqual("Mark Zuckerberg's most-shared site of {$year}", $result->headline);
     $this->assertEqual("Looks like <strong>lifehacker.com</strong> owes Mark Zuckerberg a thank you. " . "In {$year}, Mark Zuckerberg directed friends to <strong>lifehacker.com</strong> more than to " . "any other site. Here are the posts with links to <strong>lifehacker.com</strong>.", $result->text);
     $this->dumpRenderedInsight($result, $this->instance, "Normal case, Facebook");
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:40,代码来源:TestOfEOYMostLinksInsight.php

示例15: testOlympic2014InsightRegeneration

 public function testOlympic2014InsightRegeneration()
 {
     // Get data ready that insight requires
     $instance = new Instance();
     $instance->id = 3;
     $instance->network_username = 'catlady99';
     $instance->network = 'twitter';
     $builders = self::setUpPublicInsight($instance);
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'These were amazing opening ceremonies in sochi!', 'pub_date' => '2014-02-07', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'The olympic closing ceremony is the greatest global event since Beyonce\'s album', 'pub_date' => '2014-02-07', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'Hope nothing else goes wrong! #sochi2014', 'pub_date' => '2014-02-19', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $posts = array();
     $insight_plugin = new Olympics2014Insight();
     $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('olympics_2014', 3, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertEqual('Do they give out medals for tweets?', $result->headline);
     $this->assertEqual('@catlady99 mentioned the Olympics 5 times since they started. That\'s kind of like ' . 'winning 5 gold medals in Twitter, right?', $result->text);
     //Add a new post that should update the insight with 2 more mentions
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'Great closing ceremony! #sochi2014', 'pub_date' => '2014-02-21', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $insight_plugin->generateInsight($instance, null, $posts, 3);
     // Assert that insight got updated
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('olympics_2014', 3, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertEqual('@catlady99 mentioned the Olympics 7 times since they started. That\'s kind of like ' . 'winning 7 gold medals in Twitter, right?', $result->text);
     $controller = new InsightStreamController();
     $_GET['u'] = 'catlady99';
     $_GET['n'] = 'twitter';
     $_GET['d'] = date('Y-m-d');
     $_GET['s'] = 'olympics_2014';
     $results = $controller->go();
     //output this to an HTML file to see the insight fully rendered
     //$this->debug($results);
     //Test email rendering
     $email_insight = $this->getRenderedInsightInEmail($result);
     //$this->debug($email_insight);
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:44,代码来源:TestOfOlympics2014Insight.php


注:本文中的InsightMySQLDAO::getInsight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。