public function testFacebook() { $this->instance->network = 'facebook'; $this->instance->network_username = '******'; $today = date('Y-m-d'); $insight_dao = DAOFactory::getDAO('InsightDAO'); $post_builders = array(); $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 3, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "I hate it all.")); $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 4, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks everyone")); // We shouldn't get three users now $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 4, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks everyone")); $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 5, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks everyone")); // We shouldn't get three users still $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 4, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 14')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks a lot")); $insight_plugin = new ThanksgivingWhoThankedYouInsight(); $insight_plugin->generateInsight($this->instance, null, $posts, 3); $result = $insight_dao->getInsight($insight_plugin->slug, $this->instance->id, $today); $data = unserialize($result->related_data); $this->assertEqual($result->headline, '2 Facebook friends were thankful for Ms. Thankable'); $this->assertEqual($result->text, "It's great to have friends who share the love. These 2 people were " . "thankful for Ms. Thankable over the past year."); $this->assertEqual(count($data['people']), 2); $this->assertEqual($data['people'][0]->username, 'Second User'); $this->assertEqual($data['people'][1]->username, 'Third User'); $this->assertEqual($data['hero_image']['alt_text'], ''); $this->assertEqual($data['hero_image']['img_link'], 'https://www.flickr.com/photos/dexxus/2981387336/'); $this->debug($this->getRenderedInsightInHTML($result)); $this->debug($this->getRenderedInsightInEmail($result)); }
public function testInstagram() { $this->instance->network = 'instagram'; $this->instance->network_username = '******'; $today = date('Y-m-d'); $insight_dao = DAOFactory::getDAO('InsightDAO'); $post_builders = array(); $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 3, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "I hate it all.")); $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 4, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks everyone")); // We shouldn't get three users now $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 4, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks everyone")); $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 5, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 9')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks everyone")); // We shouldn't get three users still $post_builders[] = FixtureBuilder::build('posts', array('author_user_id' => 4, 'author_username' => 'testy', 'network' => $this->instance->network, 'pub_date' => date('Y-m-d', strtotime('January 14')), 'in_reply_to_user_id' => $this->instance->network_user_id, 'post_text' => "Thanks a lot")); $insight_plugin = new ThanksgivingWhoThankedYouInsight(); $insight_plugin->generateInsight($this->instance, null, $posts, 3); $result = $insight_dao->getInsight($insight_plugin->slug, $this->instance->id, $today); $this->assertIsNull($result); }