Beispiel #1
0
 public function testFrequencyInsightPriorEqualBaseline()
 {
     // Get data ready that insight requires
     $posts = self::getTestPostObjects();
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_username = '******';
     $instance->network = 'twitter';
     $insight_plugin = new FrequencyInsight();
     // 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' => 'frequency', 'instance_id' => 10, 'value' => 5));
     $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('frequency', 10, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertPattern('/\\@testeriffic posted/', $result->text);
     $this->assertPattern('/5 times/', $result->text);
     //assert no comparison to prior week
     $this->assertNoPattern('/prior week/', $result->text);
     $this->assertPattern('/Post rate:/', $result->headline);
 }
 public function testFrequencyInsightPriorEqualBaseline()
 {
     // Get data ready that insight requires
     $posts = self::getTestPostObjects();
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_username = '******';
     $instance->network = 'twitter';
     $insight_plugin = new FrequencyInsight();
     // 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' => 'frequency', 'instance_id' => 10, 'value' => 5));
     // Assert that week-over-week comparison is correct
     $insight_dao = new InsightMySQLDAO();
     $insight_plugin->generateInsight($instance, null, $posts, 3);
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('frequency', 10, $today);
     $this->assertNull($result);
 }