public function testNoHealthyShareLikes() { // Get data ready that insight requires $instance = new Instance(); $instance->id = 10; $instance->network_username = '******'; $instance->network = 'twitter'; $posts = array(); $posts[] = new Post(array('reply_count_cache' => 5, 'retweet_count_cache' => 15, 'favlike_count_cache' => 3)); $posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 5, 'favlike_count_cache' => 15)); $posts[] = new Post(array('reply_count_cache' => 2, 'retweet_count_cache' => 5, 'favlike_count_cache' => 1)); $insight_dao = new InsightMySQLDAO(); $insight_plugin = new ResponseTimeInsight(); TimeHelper::setTime(2); $insight_plugin->generateInsight($instance, null, $posts, 3); $result = $insight_dao->getInsight('response_time', 10, date('Y-m-d')); $this->assertEqual("That's a healthy share of the 21 million tweets each hour.", $result->text); $posts = array(); $posts[] = new Post(array('reply_count_cache' => 5, 'retweet_count_cache' => 15, 'favlike_count_cache' => 13)); $posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 5, 'favlike_count_cache' => 15)); $posts[] = new Post(array('reply_count_cache' => 2, 'retweet_count_cache' => 5, 'favlike_count_cache' => 15)); TimeHelper::setTime(2); $insight_plugin->generateInsight($instance, null, $posts, 3); $result = $insight_dao->getInsight('response_time', 10, date('Y-m-d')); $this->assertNotEqual("That's a healthy share of the 21 million tweets each hour.", $result->text); }
public function testResponseTimeInsightWithUnitTimeValue() { // Get data ready that insight requires $instance = new Instance(); $instance->id = 10; $instance->network_username = '******'; $instance->network = 'twitter'; $posts = array(); $posts[] = new Post(array('reply_count_cache' => 0, 'retweet_count_cache' => 0, 'favlike_count_cache' => 24 * 7)); // 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' => 'response_count_like', 'instance_id' => 10, 'value' => 7)); $insight_plugin = new ResponseTimeInsight(); $insight_plugin->generateInsight($instance, $posts, 3); // Assert that insight got inserted $insight_dao = new InsightMySQLDAO(); $today = date('Y-m-d'); $result = $insight_dao->getInsight('response_time', 10, $today); $this->debug(Utils::varDumpToString($result)); $this->assertNotNull($result); $this->assertIsA($result, "Insight"); $this->assertPattern('/\\@testeriffic\'s tweets averaged <strong>1 new favorite/', $result->text); $this->assertPattern('/every <strong>hour<\\/strong>/', $result->text); $this->assertPattern('/faster than the previous week\'s average/', $result->text); $this->assertPattern('/of 1 favorite every day./', $result->text); }