public function testFetchNewestPosts() { $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->profile3_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); //Check if newest posts are returned. try { $ic->fetchPostsAndReplies(); } catch (Exception $e) { //print_r($e); } $post = $photo_dao->getPhoto('519671854563291086', 'instagram'); $this->assertEqual($post->post_id, '519671854563291086'); $this->assertFalse($post->is_short_video); $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'); }
public function testAddPhoto() { $dao = new PhotoMySQLDAO(); $photo['post_id'] = '3454352543543543'; $photo['author_user_id'] = '1'; $photo['author_username'] = '******'; $photo['author_fullname'] = 'aaron kalair'; $photo['author_avatar'] = 'http://www.avatarland.com'; $photo['post_text'] = 'This is my amazing picture'; $photo['source'] = 'web'; $photo['is_protected'] = false; $photo['pub_date'] = '2013-12-09 12:00:00'; $photo['network'] = 'instagram'; $photo['filter'] = 'hipster'; $photo['standard_resolution_url'] = 'http://distilleryimage0.s3.amazonaws.com/yhgfdh_7.jpg'; $photo['low_resolution_url'] = 'http://distilleryimage0.s3.amazonaws.com/yhgfdh_6.jpg'; $photo['thumbnail_url'] = 'http://distilleryimage0.s3.amazonaws.com/yhgfdh_5.jpg'; $dao->addPhoto($photo); // Now check all the values were inserted $result = $dao->getPhoto('3454352543543543', 'instagram'); $this->assertTrue(isset($result)); $this->assertEqual($result->post_id, '3454352543543543'); $this->assertEqual($result->author_user_id, '1'); $this->assertEqual($result->author_username, 'aaron'); $this->assertEqual($result->author_fullname, 'aaron kalair'); $this->assertEqual($result->author_avatar, 'http://www.avatarland.com'); $this->assertEqual($result->post_text, 'This is my amazing picture'); $this->assertEqual($result->is_protected, false); $this->assertEqual($result->source, 'web'); $this->assertEqual($result->pub_date, '2013-12-09 12:00:00'); $this->assertEqual($result->network, 'instagram'); $this->assertEqual($result->filter, 'hipster'); $srurl = 'http://distilleryimage0.s3.amazonaws.com/yhgfdh_7.jpg'; $this->assertEqual($result->standard_resolution_url, $srurl); $lrurl = 'http://distilleryimage0.s3.amazonaws.com/yhgfdh_6.jpg'; $this->assertEqual($result->low_resolution_url, $lrurl); $tnurl = 'http://distilleryimage0.s3.amazonaws.com/yhgfdh_5.jpg'; $this->assertEqual($result->thumbnail_url, $tnurl); }