Exemplo n.º 1
0
 public function testFetchPostsAndRepliesForProfile2()
 {
     //Test post with a link to a video
     $fbc2 = new FacebookCrawler($this->profile2_instance, 'fauxaccesstoken', 10);
     $fbc2->fetchPostsAndReplies();
     $post_dao = new PostMySQLDAO();
     $user_dao = new UserMySQLDAO();
     $post = $post_dao->getPost('10150328374252744', 'facebook');
     $this->assertEqual($post->post_text, '');
     $this->assertEqual(sizeof($post->links), 1);
     $this->assertEqual($post->links[0]->url, 'http://www.youtube.com/v/DC1g_Aq3dUc?feature=autoshare&version=3&autohide=1&autoplay=1');
     $this->assertEqual($post->links[0]->expanded_url, '');
     $this->assertEqual($post->links[0]->caption, 'Liked on www.youtube.com');
     $this->assertEqual($post->links[0]->description, 'A fan made trailer for the Warner Bros. production of Superman Returns. Fan trailer produced and edited by ' . 'Julian Francis Adderley.');
     $this->assertEqual($post->links[0]->title, 'Superman Restored (Theatrical Trailer)');
     $this->assertEqual($post->links[0]->post_key, 1);
     // Test Facebook paging by confirming post on second "page"
     $post = $post_dao->getPost('10150357566827744', 'facebook');
     $this->assertNotNull($post);
     $this->assertEqual($post->author_user_id, '729597743');
     // Test Facebook friends and followers. This user only exists in testing as a "friend."
     $user = $user_dao->getUserByName('Poppy Linford', 'facebook');
     $this->assertTrue(isset($user));
     $this->assertEqual($user->user_id, '682523675');
     // Test follow is set
     $follow_dao = new FollowMySQLDAO();
     $this->assertTrue($follow_dao->followExists('729597743', '682523675', 'facebook'));
     // Test FollowerCount is set
     $sql = "SELECT * FROM " . $this->table_prefix . "follower_count WHERE network='facebook' AND network_user_id='729597743';";
     $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'], 1);
 }
Exemplo n.º 2
0
 public function testUpdateStaleFollows()
 {
     //Insert stale follows for 502993749
     $builders[] = FixtureBuilder::build('follows', array('user_id' => '502993749', 'first_seen' => '-5d', 'follower_id' => '123-both-follow', 'network' => 'instagram', 'last_seen' => '-5d', 'active' => 1));
     $builders[] = FixtureBuilder::build('follows', array('user_id' => '123-both-follow', 'first_seen' => '-5d', 'follower_id' => '502993749', 'network' => 'instagram', 'last_seen' => '-5d', 'active' => 1));
     $builders[] = FixtureBuilder::build('follows', array('user_id' => '502993749', 'first_seen' => '-5d', 'follower_id' => '123-source-follows', 'network' => 'instagram', 'last_seen' => '-5d', 'active' => 1));
     $builders[] = FixtureBuilder::build('follows', array('user_id' => '123-target-follows', 'first_seen' => '-5d', 'follower_id' => '502993749', 'network' => 'instagram', 'last_seen' => '-5d', 'active' => 1));
     //Run the crawl
     $ic = new InstagramCrawler($this->profile3_instance, 'fauxaccesstoken', 120);
     $ic->updateStaleFollows();
     $follow_dao = new FollowMySQLDAO();
     //Assert source follows but target doesn't
     //Target follows source - false
     $result = $follow_dao->followExists($user_id = '502993749', $follower_id = '123-source-follows', 'instagram', $is_active = true);
     $this->assertFalse($result);
     //Source follows target - true
     $result = $follow_dao->followExists($user_id = '123-source-follows', $follower_id = '502993749', 'instagram', $is_active = true);
     $this->assertTrue($result);
     //Assert target follows but source doesn't
     //Target follows source - true
     $result = $follow_dao->followExists($user_id = '502993749', $follower_id = '123-target-follows', 'instagram', $is_active = true);
     $this->assertTrue($result);
     //Source follows target - false
     $result = $follow_dao->followExists($user_id = '123-target-follows', $follower_id = '502993749', 'instagram', $is_active = true);
     $this->assertFalse($result);
     //Assert both follow
     //Target follows source - true
     $result = $follow_dao->followExists($user_id = '502993749', $follower_id = '123-both-follow', 'instagram', $is_active = true);
     $this->assertTrue($result);
     //Source follows target - true
     $result = $follow_dao->followExists($user_id = '123-both-follow', $follower_id = '502993749', 'instagram', $is_active = true);
     $this->assertTrue($result);
 }