Exemplo n.º 1
0
 public function testInteractionsInsightMentionCasesIgnored()
 {
     // Get data ready that insight requires
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_username = '******';
     $instance->network = 'twitter';
     $builders = array();
     $builders[] = FixtureBuilder::build('users', array('user_id' => '7612345', 'user_name' => 'TwitterTestUser', 'full_name' => 'Twitter Test User', 'avatar' => 'avatar.jpg', 'follower_count' => 36000, 'is_protected' => 0, 'network' => 'twitter', 'description' => 'A test Twitter user'));
     $posts = array();
     $posts[] = new Post(array('post_text' => "Blah blah bleh @TwitterTestUser blah", 'pub_date' => date("Y-m-d H:i:s", strtotime('-2 days'))));
     $posts[] = new Post(array('post_text' => "Blah blah bleh @Twittertestuser blah blah", 'pub_date' => date("Y-m-d H:i:s", strtotime('-2 days'))));
     $posts[] = new Post(array('post_text' => "Blah blah @twitterTestUser blah", 'pub_date' => date("Y-m-d H:i:s", strtotime('-2 days'))));
     $posts[] = new Post(array('post_text' => "Blah blah @tWiTTerTeSTusEr blah bleh", 'pub_date' => date("Y-m-d H:i:s", strtotime('-2 days'))));
     $insight_plugin = new InteractionsInsight();
     $insight_plugin->generateInsight($instance, $posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight("interactions", 10, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $dataset = unserialize($result->related_data);
     $this->assertIsA($result, "Insight");
     $this->assertPattern('/\\@testeriffic mentioned /', $result->text);
     $this->assertPattern('/\\@TwitterTestUser <strong>4 times/', $result->text);
     $this->assertEqual($dataset[0]['mention'], '@TwitterTestUser');
     $this->assertEqual($dataset[0]['count'], 4);
     $this->assertEqual($dataset[0]['user']->full_name, "Twitter Test User");
 }
 public function testInteractionsInsightTextFacebook()
 {
     // Get data ready that insight requires
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_username = '******';
     $instance->network = 'facebook';
     $posts = array();
     $posts[] = new Post(array('post_text' => "Blah blah bleh @mentionOne @mentionTwo blah", 'pub_date' => date("Y-m-d H:i:s", strtotime('-2 days')), 'in_reply_to_user_id' => 1));
     $posts[] = new Post(array('post_text' => "Blah blah bleh @mentionOne blah", 'pub_date' => date("Y-m-d H:i:s", strtotime('-2 days')), 'in_reply_to_user_id' => 1));
     $builders = array();
     $builders[] = FixtureBuilder::build('users', array('user_id' => '1', 'user_name' => 'Bob Mentioned', 'full_name' => 'Twitter Test User', 'avatar' => 'avatar.jpg', 'follower_count' => 36000, 'is_protected' => 0, 'network' => 'facebook', 'description' => 'A test Twitter user'));
     $insight_plugin = new InteractionsInsight();
     $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("interactions", 10, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertPattern('/Talky Person replied to Bob Mentioned /', $result->headline);
     $this->assertPattern('/Bob Mentioned <strong>twice<\\/strong> last week/', $result->headline);
     $this->debug($this->getRenderedInsightInHTML($result));
     $this->debug($this->getRenderedInsightInEmail($result));
 }