本文整理汇总了PHP中TimeHelper::setTime方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeHelper::setTime方法的具体用法?PHP TimeHelper::setTime怎么用?PHP TimeHelper::setTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeHelper
的用法示例。
在下文中一共展示了TimeHelper::setTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAlternateText
public function testAlternateText()
{
TimeHelper::setTime(3);
// Get data ready that insight requires
$builders = self::buildDataTeens();
$instance = new Instance();
$instance->id = 100;
$instance->network_user_id = 1;
$instance->network_username = 'Teen Dude';
$instance->network = 'facebook';
$post_dao = new PostMySQLDAO();
$last_week_of_posts = $post_dao->getAllPostsByUsernameOrderedBy($instance->network_username, $network = $instance->network, $count = 0, $order_by = "pub_date", $in_last_x_days = $number_days, $iterator = false, $is_public = false);
$insight_plugin = new AgeAnalysisInsight();
$insight_plugin->generateInsight($instance, null, $last_week_of_posts, 5);
// Assert that insight got inserted
$insight_dao = new InsightMySQLDAO();
$today = date('Y-m-d');
$result = $insight_dao->getInsight('age_analysis', 100, $today);
$related_data = unserialize($result->related_data);
$this->assertNotNull($result);
$this->assertIsA($result, "Insight");
$this->assertEqual($result->headline, 'Teens said it all');
$this->assertEqual($result->text, "Teens — people less than 18 years old — wrote 100% of the " . "comments on Teen Dude's Facebook posts this week.");
$this->assertEqual($related_data['age_data']['18'], 2);
$this->assertEqual($related_data['age_data']['18_25'], 0);
$this->assertEqual($related_data['age_data']['25_35'], 0);
$this->assertEqual($related_data['age_data']['35_45'], 0);
$this->assertEqual($related_data['age_data']['45'], 0);
$result->id = 1;
$this->debug($this->getRenderedInsightInHTML($result));
$this->debug($this->getRenderedInsightInEmail($result));
}
示例2: testHelloThinkUpInsight
public function testHelloThinkUpInsight()
{
$posts = array();
$instance = new Instance();
$instance->id = 1;
$instance->network_username = 'Katniss Everdeen';
$instance->network = 'facebook';
$builders = self::setUpPublicInsight($instance);
// We have three random options, so we'll check each one here.
TimeHelper::setTime(3);
$hello_thinkup_insight_plugin = new HelloThinkUpInsight();
$hello_thinkup_insight_plugin->generateInsight($instance, null, $posts, 3);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$result = $insight_dao->getInsight('my_test_insight_hello_thinkup', 1, date('Y-m-d'));
$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);
TimeHelper::setTime(4);
$hello_thinkup_insight_plugin->generateInsight($instance, null, $posts, 3);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$result = $insight_dao->getInsight('my_test_insight_hello_thinkup', 1, date('Y-m-d'));
$this->assertEqual($result->headline, 'Hello');
$this->assertEqual($result->text, 'Greetings, earthlings');
TimeHelper::setTime(5);
$hello_thinkup_insight_plugin->generateInsight($instance, null, $posts, 3);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$result = $insight_dao->getInsight('my_test_insight_hello_thinkup', 1, date('Y-m-d'));
$this->assertEqual($result->headline, 'Yo');
$this->assertEqual($result->text, 'Greetings, peeps');
/**
* Use this code to output the individual insight's fully-rendered 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.html
*/
$controller = new InsightStreamController();
$_GET['u'] = 'Katniss Everdeen';
$_GET['n'] = 'facebook';
$_GET['d'] = date('Y-m-d');
$_GET['s'] = 'my_test_insight_hello_thinkup';
$results = $controller->go();
//Uncomment this out to see web view of insight
//$this->debug($results);
/**
* 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
*/
$email_insight = $this->getRenderedInsightInEmail($result);
//Uncomment this out to see the email view of insight
//$this->debug($email_insight);
}
示例3: testSetClearTime
public function testSetClearTime()
{
$start = TimeHelper::getTime();
$this->assertNotEqual($start, 4179);
TimeHelper::setTime(4179);
$now = TimeHelper::getTime();
$this->assertEqual(4179, $now);
TimeHelper::clearTime();
$now = TimeHelper::getTime();
$this->assertNotEqual(4179, $now);
}
示例4: setUp
public function setUp()
{
parent::setUp();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = 42;
$instance->network_username = 'testy';
$instance->network = 'twitter';
$this->instance = $instance;
TimeHelper::setTime(1418947200);
// Set it to the December 2014 words timeframe
}
示例5: setUp
public function setUp()
{
parent::setUp();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = 42;
$instance->network_username = 'testy';
$instance->network = 'twitter';
$this->instance = $instance;
TimeHelper::setTime(1425329077);
// Set it to the March 2015 words timeframe
}
示例6: setUp
public function setUp()
{
parent::setUp();
$instance = new Instance();
$instance->id = 1;
$instance->network_user_id = 42;
$instance->network_username = 'bookworm';
$instance->network = 'twitter';
$this->instance = $instance;
$this->insight_dao = DAOFactory::getDAO('InsightDAO');
TimeHelper::setTime(2);
// Force one headline for most tests
}
示例7: testAlternateHeadline2
public function testAlternateHeadline2()
{
TimeHelper::setTime(3);
$builders[] = FixtureBuilder::build('posts', array('id' => 135, 'post_id' => 135, 'author_user_id' => 1234, 'author_username' => $this->instance->network_username, 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => 'twitter', 'post_text' => 'This is a post http://t.co/B5LAotKMWY with a link.', 'source' => 'web', 'pub_date' => date('Y-m-d', strtotime('-8 days')), 'reply_count_cache' => 0, 'is_protected' => 0));
$builders[] = FixtureBuilder::Build('links', array('post_key' => 135, 'url' => 'http://pic.twitter.com/vx4YL7Yz', 'image_src' => 'http://pic.twitter.com.foo.jpg', 'expanded_url' => ''));
$insight_plugin = new PhotoPromptInsight();
$insight_dao = DAOFactory::getDAO('InsightDAO');
$posts = array();
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight('photoprompt', $this->instance->id, date('Y-m-d'));
$this->assertNotNull($result);
$this->assertEqual("A great time for a pic", $result->headline);
$this->assertEqual("@anseladams hasn't posted a photo in 8 days. " . "It might be worth finding something to share.", $result->text);
$this->debug($this->getRenderedInsightInHTML($result));
$this->debug($this->getRenderedInsightInEmail($result));
}
示例8: testDiffEncoding
/**
* This test will fail on PHP 5.3, which won't display the diff with the bullet point correctly in the rendered HTML
*/
public function testDiffEncoding()
{
$builders = array();
// User
$builders[] = FixtureBuilder::build('users', array('user_id' => '1', 'user_name' => 'nosey', 'full_name' => 'Twitter User', 'follower_count' => 1, 'is_protected' => 1, 'id' => 1, 'avatar' => 'https://pbs.twimg.com/profile_images/476939811702718464/Qq0LPfRy_400x400.jpeg', 'network' => 'twitter', 'description' => 'A test Twitter User', 'location' => 'San Francisco, CA'));
// Friend
$builders[] = FixtureBuilder::build('users', array('user_id' => '2', 'user_name' => 'newlywed', 'post_count' => 101, 'follower_count' => 36000, 'is_protected' => 0, 'friend_count' => 1, 'full_name' => 'Popular Gal', 'avatar' => 'https://pbs.twimg.com/profile_images/476939811702718464/Qq0LPfRy_400x400.jpeg', 'id' => 2, 'network' => 'twitter', 'description' => 'Cofounder @thinkup & @activateinc • Writer @Medium', 'location' => 'San Francisco, CA', 'is_verified' => 0));
// Follows
$builders[] = FixtureBuilder::build('follows', array('user_id' => '2', 'follower_id' => '1', 'last_seen' => '-0d', 'first_seen' => '-0d', 'network' => 'twitter', 'active' => 1));
// Change
$builders[] = FixtureBuilder::build('user_versions', array('user_key' => 2, 'field_name' => 'description', 'field_value' => "Cofounder @thinkup & @activateinc • Writer @Medium & @Wired • " . 'Blog: http://t.co/5p9HDVJDna • anil@dashes.com • 646 833-8659 • Sign up: https://t.co/1m3JNdJKwy', 'crawl_time' => '-2d'));
$builders[] = FixtureBuilder::build('user_versions', array('user_key' => 3, 'field_name' => 'description', 'field_value' => "Cofounder @thinkup & @activateinc • Writer @Medium & @Wired", 'crawl_time' => '-3d'));
$user_dao = DAOFactory::getDAO('UserDAO');
$user = $user_dao->getDetailsByUserKey(1);
$insight_plugin = new BioTrackerInsight();
$insight_dao = new InsightMySQLDAO();
TimeHelper::setTime(1);
$insight_plugin->generateInsight($this->instance, $user, $posts, 3);
$result = $insight_dao->getInsight($insight_plugin->slug_bio, 10, $this->today);
$this->assertNotNull($result);
$rendered_html = $this->getRenderedInsightInHTML($result);
$this->assertPattern('/Cofounder @thinkup & @activateinc • Writer /', $rendered_html);
$this->debug($rendered_html);
}
示例9: testAlternateText
public function testAlternateText()
{
TimeHelper::setTime(1);
$insight_dao = DAOFactory::getDAO('InsightDAO');
$post_builders = array();
$post_builders[] = FixtureBuilder::build('posts', array('author_username' => 'testy', 'network' => 'twitter', 'post_text' => 'Thanks thank you thanks a lot!.', 'pub_date' => date('Y-m-d')));
$insight_plugin = new ThanksCountInsight();
$today = date('Y-m-d');
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight($insight_plugin->getSlug(), $this->instance->id, $today);
$this->assertNotNull($result);
$this->assertPattern('/\\@testy tweeted <strong>1 thank-you<\\/strong> last month./', $result->text);
$post_builders[] = FixtureBuilder::build('posts', array('author_username' => 'testy', 'network' => 'twitter', 'post_text' => 'Thanks thank you thanks a lot!.', 'pub_date' => date('Y-m-d')));
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight($insight_plugin->getSlug(), $this->instance->id, $today);
$this->assertNotNull($result);
$this->assertPattern('/\\@testy tweeted <strong>2 thank-yous<\\/strong> last month./', $result->text);
$this->debug($this->getRenderedInsightInHTML($result));
$this->debug($this->getRenderedInsightInEmail($result));
}
示例10: testBadJoinDate
public function testBadJoinDate()
{
$insight_plugin = new TwitterBirthdayInsight();
TimeHelper::setTime(1 + 365 * 24 * 60 * 60);
$user = $this->makeUser('hbtome', date('r', 1));
$insight_plugin->generateInsight($this->instance, $user, array(), 3);
$insight_dao = new InsightMySQLDAO();
$today = date('Y-m-d');
$result = $insight_dao->getInsight('twitterbirthday', 10, $today);
$this->assertNull($result);
}
示例11: testPhotoSkipping
public function testPhotoSkipping()
{
$insight_dao = DAOFactory::getDAO('InsightDAO');
$post_builders = array();
$days_ago_3 = date('Y-m-d H:i:s', strtotime('-3 days'));
$builders[] = FixtureBuilder::build('posts', array('id' => 444, 'post_id' => 444, 'author_user_id' => 7612345, 'author_username' => 'testeriffic', 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'in_reply_to_user_id' => NULL, 'in_retweet_of_post_id' => NULL, 'network' => 'twitter', 'post_text' => 'This is an old post http://www.aaa.com/1 with a link.', 'source' => 'web', 'pub_date' => $days_ago_3, 'reply_count_cache' => 0, 'is_protected' => 0));
$builders[] = FixtureBuilder::build('links', array('url' => 'http://www.aaaa.com/', 'title' => 'Link 1', 'post_key' => 444, 'expanded_url' => 'http://www.aaaa.com/', 'error' => '', 'image_src' => 'http://photo.com/photo.jpg'));
TimeHelper::setTime(2);
$instance = new Instance();
$instance->id = 10;
$instance->network_user_id = 7612345;
$instance->network_username = 'testeriffic';
$instance->network = 'twitter';
$insight_plugin = new DiversifyLinksInsight();
$insight_plugin->generateInsight($instance, null, $posts, 3);
$today = date('Y-m-d');
$result = $insight_dao->getInsight('diversify_links_monthly', 10, $today);
$this->assertNull($result);
$builders[] = FixtureBuilder::build('posts', array('id' => 445, 'post_id' => 445, 'author_user_id' => 7612345, 'author_username' => 'testeriffic', 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'in_reply_to_user_id' => NULL, 'in_retweet_of_post_id' => NULL, 'network' => 'twitter', 'post_text' => 'This is an old post http://www.aaa.com/1 with a link.', 'source' => 'web', 'pub_date' => $days_ago_3, 'reply_count_cache' => 0, 'is_protected' => 0));
$builders[] = FixtureBuilder::build('links', array('url' => 'http://www.aaaa.com/', 'title' => 'Link 1', 'post_key' => 445, 'expanded_url' => 'http://www.aaaa.com/', 'error' => '', 'image_src' => ''));
$insight_plugin->generateInsight($instance, null, $posts, 3);
$result = $insight_dao->getInsight('diversify_links_monthly', 10, $today);
$this->assertEqual($result->text, 'It was the best of tabs, it was the worst of tabs. @testeriffic tweeted ' . '1 link to aaaa.com this month.');
$this->assertEqual("@testeriffic's most linked-to site this month", $result->headline);
$this->debug($this->getRenderedInsightInHTML($result));
$this->debug($this->getRenderedInsightInEmail($result));
}
示例12: testHeadlines
public function testHeadlines()
{
$posts = self::getTestPostObjects();
$insight_plugin = new AllAboutYouInsight();
$today = date('Y-m-d');
$insight_plugin = new AllAboutYouInsight();
$insight_dao = DAOFactory::getDAO('InsightDAO');
$good_headlines = array(null, 'Sometimes it\'s all about @testeriffic', 'It\'s getting personal', 'A moment of self-reflection', 'Sometimes Twitter is a first-person story', 'A story about @testeriffic');
for ($i = 1; $i <= 5; $i++) {
TimeHelper::setTime($i);
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight('all_about_you', 10, $today);
$this->assertEqual($result->headline, $good_headlines[$i]);
}
}
示例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: testWeeklyBestsInsightWithRepliesAndFavorites
public function testWeeklyBestsInsightWithRepliesAndFavorites()
{
// Get data ready that insight requires
$instance = new Instance();
$instance->id = 10;
$instance->network_username = 'testeriffic';
$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);
}
示例15: testAlternateHeadlines
public function testAlternateHeadlines()
{
$insight_dao = DAOFactory::getDAO('InsightDAO');
$post_builders = array();
$post_builders[] = FixtureBuilder::build('posts', array('author_username' => 'screamy', 'network' => 'twitter', 'post_text' => 'Woo!', 'pub_date' => date('Y-m-d')));
$insight_plugin = new ExclamationCountInsight();
$today = date('Y-m-d');
$headlines = array('', 'OMG @screamy is serious!', '30 days of !!!');
for ($i = 1; $i < 3; $i++) {
TimeHelper::setTime($i);
$insight_plugin->generateInsight($this->instance, null, $posts, 3);
$result = $insight_dao->getInsight($insight_plugin->getSlug(), $this->instance->id, $today);
$this->assertNotNull($result);
$this->assertEqual($result->headline, $headlines[$i]);
$this->assertNull($result->related_data);
}
$this->debug($this->getRenderedInsightInHTML($result));
$this->debug($this->getRenderedInsightInEmail($result));
}