public function testAllAboutYouInsightPriorEqualBaseline() { // Get data ready that insight requires $posts = self::getTestPostObjects(); $instance = new Instance(); $instance->id = 10; $instance->network_username = '******'; $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); }
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]); } }