/** * This test checks 'old-style' rt handling and mentions */ public function testAddPostOldStyleRTNoPostID() { list($post, $entities, $user_array) = $this->buildStreamPostArray3(); $dao = new PostMySQLDAO(); $user_dao = new UserMySQLDAO(); $dao->addPostAndAssociatedInfo($post, $entities, $user_array); $post = $dao->getPost('39088041628934144', 'twitter'); $this->assertEqual($post->in_rt_of_user_id, 40025121); $user = $user_dao->getDetails(140955302, 'twitter'); $this->assertEqual($user->username, 'DAaronovitch'); $m_dao = new MentionMySQLDAO(); $mention = $m_dao->getMentionInfoUserID(40025121); $mp = $m_dao->getMentionsForPost('39088041628934144'); $this->assertTrue($mention != null); $this->assertEqual($mention['user_name'], 'RSAMatthew'); $this->assertEqual($mention['count_cache'], 1); $this->assertEqual($mp[0]['author_user_id'], 140955302); }
public function testFetchPostsAndRepliesForPage() { $fbc = new FacebookCrawler($this->page1_instance, 'fauxaccesstoken', 10); $fbc->fetchPostsAndReplies(); $post_dao = new PostMySQLDAO(); $post = $post_dao->getPost('437900891355', 'facebook page'); $this->assertEqual($post->post_text, 'Top 10 iOS Jailbreak Hacks'); $this->assertFalse($post->is_protected); $this->assertEqual($post->reply_count_cache, 8); //test link with image $this->assertEqual(sizeof($post->links), 1); $this->assertEqual($post->links[0]->url, 'http://lifehacker.com/5653429/top-10-ios-jailbreak-hacks'); $this->assertEqual($post->links[0]->expanded_url, ''); $this->assertEqual($post->links[0]->image_src, 'http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=45439413586&v=1&size=z&cksum=7de062ac249fe7caef80f66' . 'f49a38818&src=http%3A%2F%2Fcache-02.gawkerassets.com%2Fassets%2Fimages%2F17%2F2010%2F10%2F160x120_jailbreak-' . 'top-10.jpg'); $this->assertEqual($post->links[0]->description, 'If you purchased an iOS device, you also signed up for its many limitations. Jailbreaking can put you back ' . 'in control. Here are ten great jailbreak hacks to help you customize and better utilize your iOS device...'); //assert user network is set to Facebook, not Facebook Page $ud = new UserMySQLDAO(); $user = $ud->getUserByName('Matthew Fleisher', 'facebook'); $this->assertEqual($user->full_name, 'Matthew Fleisher'); $this->assertEqual($user->network, 'facebook'); $this->assertTrue($user->is_protected); $user = $ud->getUserByName('Matthew Fleisher', 'facebook page'); $this->assertEqual($user, null); $fav_dao = new FavoritePostMySQLDAO(); $favs = $fav_dao->getUsersWhoFavedPost('437894121355', 'facebook page'); $this->assertEqual($favs[0]['user_name'], 'Tigger Pike'); $this->assertEqual($favs[0]['user_id'], '641265671'); // Test Facebook paging by confirming post on second "page" was captured $post = $post_dao->getPost('437660146355', 'facebook page'); $this->assertNotNull($post); $this->assertEqual($post->author_user_id, '7568536355'); // Test FollowerCount is set $sql = "SELECT * FROM " . $this->table_prefix . "follower_count WHERE network='facebook page' AND network_user_id='7568536355';"; $stmt = FollowerCountMySQLDAO::$PDO->query($sql); $data = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { array_push($data, $row); } $stmt->closeCursor(); $this->assertEqual($data[0]['count'], 307758); }
public function testFetchPageStream() { $fbc = new FacebookCrawler($this->instance, 'fauxaccesstoken'); $fbc->fetchPostsAndReplies('7568536355', true); $post_dao = new PostMySQLDAO(); $post = $post_dao->getPost('437900891355', 'facebook page'); $this->assertEqual($post->post_text, 'Top 10 iOS Jailbreak Hacks'); $this->assertFalse($post->is_protected); $this->assertEqual($post->reply_count_cache, 8); //test link with image $this->assertNotNull($post->link); $this->assertEqual($post->link->url, 'http://lifehacker.com/5653429/top-10-ios-jailbreak-hacks'); $this->assertEqual($post->link->expanded_url, 'http://lifehacker.com/5653429/top-10-ios-jailbreak-hacks'); $this->assertEqual($post->link->image_src, 'http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=45439413586&v=1&size=z&cksum=7de062ac249fe7caef80f66' . 'f49a38818&src=http%3A%2F%2Fcache-02.gawkerassets.com%2Fassets%2Fimages%2F17%2F2010%2F10%2F160x120_jailbreak-' . 'top-10.jpg'); $this->assertEqual($post->link->description, 'If you purchased an iOS device, you also signed up for its many limitations. Jailbreaking can put you back ' . 'in control. Here are ten great jailbreak hacks to help you customize and better utilize your iOS device...'); //assert user network is set to Facebook, not Facebook Page $ud = new UserMySQLDAO(); $user = $ud->getUserByName('Matthew Fleisher', 'facebook'); $this->assertEqual($user->full_name, 'Matthew Fleisher'); $this->assertEqual($user->network, 'facebook'); $this->assertTrue($user->is_protected); $user = $ud->getUserByName('Matthew Fleisher', 'facebook page'); $this->assertEqual($user, null); $fav_dao = new FavoritePostMySQLDAO(); $favs = $fav_dao->getUsersWhoFavedPost('437894121355', 'facebook page'); $this->assertEqual($favs[0]['user_name'], 'Tigger Pike'); $this->assertEqual($favs[0]['user_id'], '641265671'); }
public function testInitializeInstanceUserExpiredToken() { $gpc = new GooglePlusCrawler($this->profile1_instance, 'faux-expired-access-token', 10); $gpc->initializeInstanceUser('ci', 'cs', 'valid_token', 'test_refresh_token', 1); $user_dao = new UserMySQLDAO(); $user = $user_dao->getUserByName('Gina Trapani', 'google+'); $this->assertTrue(isset($user)); $this->assertEqual($user->username, 'Gina Trapani'); $this->assertEqual($user->full_name, 'Gina Trapani'); $this->assertEqual($user->user_id, '113612142759476883204'); $this->assertEqual($user->location, "San Diego"); $this->assertEqual($user->description, 'ThinkUp lead developer, This Week in Google co-host, Todo.txt apps creator, founding editor of Lifehacker'); $this->assertEqual($user->url, ''); $this->assertFalse($user->is_protected); }
public function testFetchPostsAndRepliesForProfile1() { $user_dao = new UserMySQLDAO(); $photo_dao = new PhotoMySQLDAO(); $count_history_dao = new CountHistoryMySQLDAO(); $favorite_dao = new FavoritePostMySQLDAO(); $follow_dao = new FollowMySQLDAO(); $ic = new InstagramCrawler($this->profile1_instance, 'fauxaccesstoken', 120); $config = Config::getInstance(); $instagram_crawler_log = $config->getValue('log_location'); // prepare log for reading after fetchPostsAndReplies $log_reader_handle = fopen($instagram_crawler_log, 'r'); fseek($log_reader_handle, 0, SEEK_END); // Fetch all of our mock testing data $ic->fetchPostsAndReplies(); $ic->fetchFollowers(); fflush($this->logger->log); $log_written = stream_get_contents($log_reader_handle); fclose($log_reader_handle); $this->assertFalse(preg_match('/InstagramCrawler::fetchPostsAndReplies,\\d+ \\| 0 Instagram posts found on page 2/', $log_written)); // Check all of our testing data is stored in the database // This picture has 1 reply and no likes $post = $photo_dao->getPhoto('519644594447805677_494785218', 'instagram'); $this->assertEqual($post->post_id, '519644594447805677_494785218'); $this->assertEqual($post->author_user_id, '494785218'); $this->assertEqual($post->author_username, 'snoopdogg'); $this->assertEqual($post->author_fullname, 'Snoop Dogg'); $avatar = 'http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg'; $this->assertEqual($post->author_avatar, $avatar); $this->assertEqual($post->post_text, 'Pwpw katapiesh...'); $this->assertEqual($post->reply_count_cache, 1); $this->assertFalse($post->is_protected); $this->assertEqual($post->favlike_count_cache, 0); $this->assertEqual($post->pub_date, '2013-08-10 20:28:00'); $this->assertEqual($post->network, 'instagram'); $permalink = 'http://instagram.com/p/c2JgFlg2zt/'; $this->assertEqual($post->permalink, $permalink); $this->assertEqual($post->filter, 'Valencia'); $sru = 'http://distilleryimage5.s3.amazonaws.com/5c3132b801fb11e38a2722000a9f1925_7.jpg'; $this->assertEqual($post->standard_resolution_url, $sru); $lru = 'http://distilleryimage5.s3.amazonaws.com/5c3132b801fb11e38a2722000a9f1925_6.jpg'; $this->assertEqual($post->low_resolution_url, $lru); $tnu = 'http://distilleryimage5.s3.amazonaws.com/5c3132b801fb11e38a2722000a9f1925_5.jpg'; $this->assertEqual($post->thumbnail_url, $tnu); // Check the reply was added $post = $photo_dao->getPhoto('519671854563291086', 'instagram'); $this->assertEqual($post->post_id, '519671854563291086'); $this->assertEqual($post->author_user_id, '502993749'); $this->assertEqual($post->author_username, 'ni_ato'); $this->assertEqual($post->author_fullname, 'niki'); $avatar = 'http://images.ak.instagram.com/profiles/anonymousUser.jpg'; $this->assertEqual($post->author_avatar, $avatar); $this->assertEqual($post->post_text, 'Epikinduna paixnidia'); $this->assertFalse($post->is_protected); $this->assertEqual($post->pub_date, '2013-08-10 20:28:00'); $this->assertEqual($post->network, 'instagram'); $this->assertEqual($post->in_reply_to_user_id, '494785218'); $this->assertEqual($post->in_reply_to_post_id, '519644594447805677_494785218'); // Check that the author of the reply was added to the users table $user = $user_dao->getUserByName('ni_ato', 'instagram'); $this->assertTrue(isset($user)); $this->assertEqual($user->username, 'ni_ato'); $this->assertEqual($user->full_name, 'niki'); $this->assertEqual($user->user_id, '502993749'); $this->assertEqual($user->avatar, 'http://images.ak.instagram.com/profiles/anonymousUser.jpg'); // User is private based on relationship data $this->assertTrue($user->is_protected); $this->assertEqual($user->network, 'instagram'); // Check the second photo was added, it has no comments and two likes $post = $photo_dao->getPhoto('519642461157682352_494785218', 'instagram'); $this->assertEqual($post->post_id, '519642461157682352_494785218'); $this->assertEqual($post->author_user_id, '494785218'); $this->assertEqual($post->author_username, 'afokou'); $this->assertEqual($post->author_fullname, 'Aggeliki Fokou'); $avatar = 'http://images.ak.instagram.com/profiles/anonymousUser.jpg'; $this->assertEqual($post->author_avatar, $avatar); $this->assertEqual($post->post_text, 'H diaskedastiki mou arxi ;('); $this->assertEqual($post->reply_count_cache, 0); $this->assertFalse($post->is_protected); $this->assertEqual($post->favlike_count_cache, 2); $this->assertEqual($post->pub_date, '2013-08-10 20:23:00'); $this->assertEqual($post->network, 'instagram'); $permalink = 'http://instagram.com/p/c2JBCzg2yw/'; $this->assertEqual($post->permalink, $permalink); $this->assertEqual($post->filter, 'X-Pro II'); $sru = 'http://distilleryimage8.s3.amazonaws.com/c49be7f401fa11e3bcc122000a1fa49d_7.jpg'; $this->assertEqual($post->standard_resolution_url, $sru); $lru = 'http://distilleryimage8.s3.amazonaws.com/c49be7f401fa11e3bcc122000a1fa49d_6.jpg'; $this->assertEqual($post->low_resolution_url, $lru); $tnu = 'http://distilleryimage8.s3.amazonaws.com/c49be7f401fa11e3bcc122000a1fa49d_5.jpg'; $this->assertEqual($post->thumbnail_url, $tnu); // Check we stored the details of the users who liked our photo (ni_ato was the second person to like it and // we checked he was in the DB above) $user = $user_dao->getUserByName('louk_as', 'instagram'); $this->assertTrue(isset($user)); $this->assertEqual($user->username, 'louk_as'); $this->assertEqual($user->full_name, 'lucas asimo'); $this->assertEqual($user->user_id, '20065178'); $this->assertEqual($user->avatar, 'http://images.ak.instagram.com/profiles/profile_20065178_75sq_1335521050.jpg'); $this->assertFalse($user->is_protected); // Check we stored the number of followers our owner has $number_of_followers = $count_history_dao->getLatestCountByNetworkUserIDAndType('494785218', 'instagram', 'followers'); $this->assertEqual($number_of_followers['count'], 3410); // Also check the relationship is in the follows table $this->assertTrue($follow_dao->followExists('494785218', '6623', 'instagram')); $this->assertTrue($follow_dao->followExists('494785218', '29648', 'instagram')); $this->assertTrue($follow_dao->followExists('494785218', '13096', 'instagram')); // Check we stored the two likes in the favorites table $fav_posts = $favorite_dao->getUsersWhoFavedPost('519642461157682352_494785218', 'instagram', true); $this->assertEqual($fav_posts[0]['user_id'], '20065178'); $this->assertEqual($fav_posts[1]['user_id'], '502993749'); }
public function testFetchPageStream() { $fbc = new FacebookCrawler($this->instance, 'fauxaccesstoken'); $fbc->fetchPagePostsAndReplies(7568536355); $pd = new PostMySQLDAO(); $post = $pd->getPost('437900891355', 'facebook page'); $this->assertEqual($post->post_text, 'Top 10 iOS Jailbreak Hacks'); $this->assertEqual($post->reply_count_cache, 8); //assert user network is set to Facebook, not Facebook Page $ud = new UserMySQLDAO(); $user = $ud->getUserByName('Matthew Fleisher', 'facebook'); $this->assertEqual($user->full_name, 'Matthew Fleisher'); $this->assertEqual($user->network, 'facebook'); $user = $ud->getUserByName('Matthew Fleisher', 'facebook page'); $this->assertEqual($user, null); }
public function testAddAndDeleteHashtagSearch() { $this->debug(__METHOD__); //Hashtag does not exist $hashtag_dao = new HashtagMySQLDAO(); $instance_hashtag_dao = new InstanceHashtagMySQLDAO(); $hashtag = $hashtag_dao->getHashtag($_POST['new_hashtag_name'], 'twitter'); $this->assertNull($hashtag); $instance_hashtag = $instance_hashtag_dao->getByInstance(1); $this->assertEqual(sizeof($instance_hashtag), 0); //Add hashtag $this->simulateLogin('*****@*****.**', true, true); $_POST['action'] = 'Save search'; $_POST['new_hashtag_name'] = '#Messi'; $_POST['instance_id'] = 1; $_POST['csrf_token'] = parent::CSRF_TOKEN; $controller = new AccountConfigurationController(true); $results = $controller->go(); $this->debug($results); $hashtag = $hashtag_dao->getHashtag($_POST['new_hashtag_name'], 'twitter'); $this->assertNotNull($hashtag); $this->assertEqual($hashtag->id, 1); $this->assertEqual($hashtag->hashtag, $_POST['new_hashtag_name']); $this->assertEqual($hashtag->network, 'twitter'); $this->assertEqual($hashtag->count_cache, 0); $instance_hashtag = $instance_hashtag_dao->getByInstance(1); $this->assertNotNull($instance_hashtag); $this->assertEqual(sizeof($instance_hashtag), 1); $this->assertEqual($instance_hashtag[0]->instance_id, 1); $this->assertEqual($instance_hashtag[0]->hashtag_id, 1); $this->assertEqual($instance_hashtag[0]->last_post_id, 0); $this->assertEqual($instance_hashtag[0]->earliest_post_id, 0); $v_mgr = $controller->getViewManager(); $success_msgs = $v_mgr->getTemplateDataItem('success_msgs'); $this->assertNotNull($success_msgs); $this->assertEqual($success_msgs['account'], 'Saved search for #Messi.'); $this->assertNull($v_mgr->getTemplateDataItem('error_msg')); //Search tweets //Saved search tweets do not exist $posts_dao = new PostMySQLDAO(); $links_dao = new LinkMySQLDAO(); $users_dao = new UserMySQLDAO(); $hashtagpost_dao = new HashtagPostMySQLDAO(); $hashtags_posts = $hashtagpost_dao->getHashtagsForPost(1, 'twitter'); $this->assertEqual(sizeof($hashtags_posts), 0); $posts = $posts_dao->getAllPostsByHashtagId(1, 'twitter', 20); $this->assertEqual(sizeof($posts), 0); $posts = $posts_dao->getAllPostsByUsername('vetcastellnou', 'twitter'); $this->assertEqual(sizeof($posts), 0); $links = $links_dao->getLinksForPost(1); $this->assertEqual(sizeof($links), 0); $this->assertFalse($users_dao->isUserInDB(100, 'twitter')); $this->assertFalse($users_dao->isUserInDB(101, 'twitter')); $builder = $this->buildSearchData(); //Saved search tweets do exist $hashtags_posts = $hashtagpost_dao->getHashtagsForPost(1, 'twitter'); $this->assertEqual(sizeof($hashtags_posts), 1); $posts = $posts_dao->getAllPostsByHashtagId(1, 'twitter', 20); $this->assertEqual(sizeof($posts), 2); $posts = $posts_dao->getAllPostsByUsername('vetcastellnou', 'twitter'); $this->assertEqual(sizeof($posts), 1); $links = $links_dao->getLinksForPost(1); $this->assertEqual(sizeof($links), 2); $this->assertTrue($users_dao->isUserInDB(100, 'twitter')); $this->assertTrue($users_dao->isUserInDB(101, 'twitter')); //Delete hashtag $new_hashtag_name = $_POST['new_hashtag_name']; unset($_POST['new_hashtag_name']); $_POST['action'] = 'Delete'; $_POST['instance_id'] = 1; $_POST['hashtag_id'] = 1; $_POST['csrf_token'] = parent::CSRF_TOKEN; $controller = new AccountConfigurationController(true); $controller->go(); $hashtags_posts = $hashtagpost_dao->getHashtagsForPost(1, 'twitter'); $this->assertEqual(sizeof($hashtags_posts), 0); $posts = $posts_dao->getAllPostsByHashtagId(1, 'twitter', 20); $this->assertEqual(sizeof($posts), 0); $posts = $posts_dao->getAllPostsByUsername('vetcastellnou', 'twitter'); $this->assertEqual(sizeof($posts), 1); $links = $links_dao->getLinksForPost(1); //Don't delete links $this->assertEqual(sizeof($links), 2); //Don't delete users $this->assertTrue($users_dao->isUserInDB(100, 'twitter')); $this->assertTrue($users_dao->isUserInDB(101, 'twitter')); $hashtag = $hashtag_dao->getHashtag($new_hashtag_name); $this->assertNull($hashtag); $instance_hashtag = $instance_hashtag_dao->getByInstance(1); $this->assertEqual(sizeof($instance_hashtag), 0); $v_mgr = $controller->getViewManager(); $success_msgs = $v_mgr->getTemplateDataItem('success_msgs'); $this->assertNotNull($success_msgs); $this->assertEqual($success_msgs['account'], 'Deleted saved search.'); $this->assertNull($v_mgr->getTemplateDataItem('error_msg')); }
public function testGetRecentFriendsVersions() { $builders = array(); $builders[] = FixtureBuilder::build('user_versions', array('user_key' => 2, 'field_name' => 'bio', 'field_value' => 'I work at CompanyCo!', 'crawl_time' => '-1d')); $builders[] = FixtureBuilder::build('user_versions', array('user_key' => 2, 'field_name' => 'bio', 'field_value' => 'I am unemployed.', 'crawl_time' => '-0d')); $builders[] = FixtureBuilder::build('user_versions', array('user_key' => 3, 'field_name' => 'bio', 'field_value' => 'My bio.', 'crawl_time' => '-0d')); $builders[] = FixtureBuilder::build('user_versions', array('user_key' => 4, 'field_name' => 'url', 'field_value' => 'http://foo.bar', 'crawl_time' => '-28h')); $builders[] = FixtureBuilder::build('follows', array('active' => 1, 'user_id' => 22, 'follower_id' => 11, 'network' => 'twitter')); $builders[] = FixtureBuilder::build('follows', array('active' => 0, 'user_id' => 33, 'follower_id' => 11, 'network' => 'twitter')); $builders[] = FixtureBuilder::build('users', array('network' => 'twitter', 'id' => 1, 'user_id' => 11)); $builders[] = FixtureBuilder::build('users', array('network' => 'twitter', 'id' => 2, 'user_id' => 22)); $builders[] = FixtureBuilder::build('users', array('network' => 'twitter', 'id' => 3, 'user_id' => 33)); $builders[] = FixtureBuilder::build('users', array('network' => 'twitter', 'id' => 4, 'user_id' => 44)); $user_dao = new UserMySQLDAO(); $user_1 = $user_dao->getDetailsByUserKey(1); $res = $this->DAO->getRecentFriendsVersions($user_1, 2); $this->assertEqual(count($res), 2); $this->assertEqual($res[0]['user_key'], 2); $this->assertEqual($res[0]['field_name'], 'bio'); $this->assertEqual($res[0]['field_value'], 'I am unemployed.'); $this->assertEqual($res[1]['user_key'], 2); $this->assertEqual($res[1]['field_name'], 'bio'); $this->assertEqual($res[1]['field_value'], 'I work at CompanyCo!'); $res = $this->DAO->getRecentFriendsVersions($user_1, 1); $this->assertEqual(count($res), 1); $this->assertEqual($res[0]['user_key'], 2); $this->assertEqual($res[0]['field_name'], 'bio'); $this->assertEqual($res[0]['field_value'], 'I am unemployed.'); $res = $this->DAO->getRecentFriendsVersions($user_1, 1, array('url')); $this->assertEqual(count($res), 0); $res = $this->DAO->getRecentFriendsVersions($user_1, 1, array('bio')); $this->assertEqual(count($res), 1); $this->assertEqual($res[0]['user_key'], 2); $this->assertEqual($res[0]['field_name'], 'bio'); $this->assertEqual($res[0]['field_value'], 'I am unemployed.'); $res = $this->DAO->getRecentFriendsVersions($user_1, 1, array('bio', 'url')); $this->assertEqual(count($res), 1); $this->assertEqual($res[0]['user_key'], 2); $this->assertEqual($res[0]['field_name'], 'bio'); $this->assertEqual($res[0]['field_value'], 'I am unemployed.'); $builders[] = FixtureBuilder::build('user_versions', array('user_key' => 2, 'field_name' => 'url', 'field_value' => 'http://company.co', 'crawl_time' => '-2d')); $res = $this->DAO->getRecentFriendsVersions($user_1, 1, array('bio', 'url')); $this->assertEqual(count($res), 1); $this->assertEqual($res[0]['user_key'], 2); $this->assertEqual($res[0]['field_name'], 'bio'); $this->assertEqual($res[0]['field_value'], 'I am unemployed.'); $res = $this->DAO->getRecentFriendsVersions($user_1, 3, array('bio', 'url')); $this->assertEqual(count($res), 3); $this->assertEqual($res[0]['user_key'], 2); $this->assertEqual($res[0]['field_name'], 'bio'); $this->assertEqual($res[0]['field_value'], 'I am unemployed.'); $this->assertEqual($res[1]['user_key'], 2); $this->assertEqual($res[1]['field_name'], 'bio'); $this->assertEqual($res[1]['field_value'], 'I work at CompanyCo!'); $this->assertEqual($res[2]['user_key'], 2); $this->assertEqual($res[2]['field_name'], 'url'); $this->assertEqual($res[2]['field_value'], 'http://company.co'); $builders[] = FixtureBuilder::build('follows', array('active' => 1, 'user_id' => 44, 'follower_id' => 11, 'network' => 'twitter')); $res = $this->DAO->getRecentFriendsVersions($user_1, 3, array('bio', 'url')); $this->assertEqual(count($res), 4); $this->assertEqual($res[0]['user_key'], 2); $this->assertEqual($res[0]['field_name'], 'bio'); $this->assertEqual($res[0]['field_value'], 'I am unemployed.'); $this->assertEqual($res[1]['user_key'], 2); $this->assertEqual($res[1]['field_name'], 'bio'); $this->assertEqual($res[1]['field_value'], 'I work at CompanyCo!'); $this->assertEqual($res[2]['user_key'], 4); $this->assertEqual($res[2]['field_name'], 'url'); $this->assertEqual($res[2]['field_value'], 'http://foo.bar'); $this->assertEqual($res[3]['user_key'], 2); $this->assertEqual($res[3]['field_name'], 'url'); $this->assertEqual($res[3]['field_value'], 'http://company.co'); $user_2 = $user_dao->getDetailsByUserKey(2); $res = $this->DAO->getRecentFriendsVersions($user_2, 2); $this->assertEqual(count($res), 0); }
public function testFetchPostsAndRepliesForPage() { $fbc = new FacebookCrawler($this->page1_instance, 'abc', 10); $fbc->fetchPostsAndReplies(); $post_dao = new PostMySQLDAO(); $post = $post_dao->getPost('10152714332426356', 'facebook page'); $this->assertEqual($post->post_text, 'Looks like a very serene place to work:'); $this->assertFalse($post->is_protected); $this->assertEqual($post->reply_count_cache, 4); //test link with image $this->assertEqual(sizeof($post->links), 1); $this->assertEqual($post->links[0]->url, 'http://lifehac.kr/Jg0mR3E'); $this->assertEqual($post->links[0]->expanded_url, ''); $this->assertEqual($post->links[0]->image_src, 'https://fbexternal-a.akamaihd.net/safe_image.php?d=AQDJyDKV3JDoU0-y&w=130&h=130&url=http%3A%2F%2' . 'Fi.kinja-img.com%2Fgawker-media%2Fimage%2Fupload%2Fs--G2ekOhHZ--%2Fgobnypf78nigkkl7cwpl.png&cfs=1'); $this->assertEqual($post->links[0]->description, 'Today’s featured workspace looks immaculate, with its pristine white walls, simple white desk, and ' . 'wood accents. Those skylights help too.'); //assert user network is set to Facebook, not Facebook Page $ud = new UserMySQLDAO(); $user = $ud->getUserByName('Gregory Robert Dumas', 'facebook'); $this->assertEqual($user->full_name, 'Gregory Robert Dumas'); $this->assertEqual($user->network, 'facebook'); $this->assertTrue($user->is_protected); $user = $ud->getUserByName('Matthew Fleisher', 'facebook page'); $this->assertEqual($user, null); $fav_dao = new FavoritePostMySQLDAO(); $favs = $fav_dao->getUsersWhoFavedPost('10152714332426356', 'facebook page'); $this->assertEqual($favs[0]['user_name'], 'Peter-Sarah Crofton'); $this->assertEqual($favs[0]['user_id'], '25913266'); // Test Facebook paging by confirming post on second "page" was captured $post = $post_dao->getPost('10152712264921356', 'facebook page'); $this->assertNotNull($post); $this->assertEqual($post->author_user_id, '7568536355'); }
public function testInitializeInstanceUser() { // Create a new foursquare crawler for this instance with the access token fauxaccesstoken $fsc = new FoursquareCrawler($this->profile1_instance, 'secret', 10); // Call the initaliseInstanceUser method with this users id and access token $fsc->initializeInstanceUser('secret', 1); // Get a new user DAO $user_dao = new UserMySQLDAO(); // Get the foursquare users object $user = $user_dao->getUserByName('*****@*****.**', 'foursquare'); // Check that we got something back from the database $this->assertTrue(isset($user)); // Check the username is correct $this->assertEqual($user->username, '*****@*****.**'); // Check the full name is correct $this->assertEqual($user->full_name, 'Bob Cats'); // Check the user ID is correct $this->assertEqual($user->user_id, '113612142759476883204'); // Check the location is correct $this->assertEqual($user->location, "Harefield, UK"); // Check the URL was set correctly $this->assertEqual($user->url, 'http://www.foursquare.com/user/113612142759476883204'); // Check the user isn't protected $this->assertFalse($user->is_protected); }