public function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); $this->DAO = new FollowMySQLDAO(); //Insert test data into test table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar) VALUES (12, 'jack', 'Jack Dorsey', 'avatar.jpg');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (13, 'ev', 'Ev Williams', 'avatar.jpg', '1/1/2005');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected) VALUES (16, 'private', 'Private Poster', 'avatar.jpg', 1);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_user_errors (user_id, error_code, error_text, error_issued_to_user_id) VALUES (15, 404, 'User not found', 13);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 12, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 14, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 15, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 16, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (16, 13, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (16, 12, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, active, last_seen) VALUES (14, 12, 0, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, active, last_seen) VALUES (13, 17, 0, '2006-01-08 23:54:41');"; PDODAO::$PDO->exec($q); }
function setUp() { parent::setUp(); //Insert test data into test table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar) VALUES (12, 'jack', 'Jack Dorsey', 'avatar.jpg');"; $this->db->exec($q); }
function setUp() { parent::setUp(); //Insert test links (not images, not expanded) $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image) VALUES ('http://bit.ly/a5VmbO', '', 0, 1, 0);"; $this->db->exec($q); }
function setUp() { parent::setUp(); $webapp = Webapp::getInstance(); $webapp->registerPlugin('facebook', 'FacebookPlugin'); $webapp->setActivePlugin('facebook'); }
function setUp() { parent::setUp(); $webapp = Webapp::getInstance(); //TODO Make this a singleton so we don't have to instantiate/globalize it $webapp->registerPlugin('twitter', 'TwitterPlugin'); //Add owner $q = "INSERT INTO tt_owners SET id=1, user_name='ThinkTankUser', full_name='ThinkTank J. User', user_email='*****@*****.**', user_activated=1, user_pwd='XXX', activation_code='8888'"; $this->db->exec($q); //Add instance_owner $q = "INSERT INTO tt_owner_instances (owner_id, instance_id) VALUES (1, 1)"; $this->db->exec($q); //Insert test data into test table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (13, 'ev', 'Ev Williams', 'avatar.jpg', '1/1/2005');"; $this->db->exec($q); //Make public $q = "INSERT INTO tt_instances (id, network_user_id, network_username, is_public) VALUES (1, 13, 'ev', 1);"; $this->db->exec($q); //Add a bunch of posts $counter = 0; while ($counter < 40) { $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$counter}, 13, 'ev', 'Ev Williams', 'avatar.jpg', 'This is post {$counter}', 'web', '2006-01-01 00:{$pseudo_minute}:00', " . rand(0, 4) . ", 5);"; $this->db->exec($q); $counter++; } }
function setUp() { parent::setUp(); //Insert test links (not images, not expanded) $counter = 0; while ($counter < 40) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image) VALUES ('http://example.com/" . $counter . "', 'Link {$counter}', 0, {$post_id}, 0);"; $this->db->exec($q); $counter++; } //Insert test links (images on Flickr that don't exist, not expanded) $counter = 0; while ($counter < 2) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image) VALUES ('http://flic.kr/p/" . $counter . "', 'Link {$counter}', 0, {$post_id}, 1);"; $this->db->exec($q); $counter++; } // Insert legit Flickr shortened link, not expanded $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image) VALUES ('http://flic.kr/p/7QQBy7', 'Link', 0, 200, 1);"; $this->db->exec($q); //Insert test links with errors (images from Flickr, not expanded) $counter = 0; while ($counter < 5) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image, error) VALUES ('http://flic.kr/p/" . $counter . "', 'Link {$counter}', 0, {$post_id}, 1, 'Generic test error message, Photo not found');"; $this->db->exec($q); $counter++; } }
function setUp() { parent::setUp(); global $THINKTANK_CFG; $r = array('id' => 1, 'network_username' => 'anildash', 'network_user_id' => '930061', 'last_status_id' => '0', 'last_page_fetched_replies' => 0, 'last_page_fetched_tweets' => '0', 'total_posts_in_system' => '0', 'total_replies_in_system' => '0', 'total_follows_in_system' => '0', 'total_users_in_system' => '0', 'is_archive_loaded_replies' => '0', 'is_archive_loaded_follows' => '0', 'crawler_last_run' => '', 'earliest_reply_in_system' => '', 'api_calls_to_leave_unmade_per_minute' => 2, 'avg_replies_per_day' => '2', 'is_public' => '0', 'is_active' => '0', 'network' => 'twitter'); $this->instance = new Instance($r); $this->api = new CrawlerTwitterAPIAccessorOAuth('111', '222', $THINKTANK_CFG['oauth_consumer_key'], $THINKTANK_CFG['oauth_consumer_secret'], $this->instance, $THINKTANK_CFG['archive_limit']); }
/** * Set Up */ public function setUp() { parent::setUp(); //Insert test data into test table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, location) VALUES (12, 'jack', 'Jack Dorsey', 'avatar.jpg', 'San Francisco');"; $this->db->exec($q); $this->logger = Logger::getInstance(); }
function setUp() { parent::setUp(); global $THINKTANK_CFG; $r = array('id' => 1, 'network_username' => 'Penelope Caridad', 'network_user_id' => '606837591', 'last_status_id' => '0', 'last_page_fetched_replies' => 0, 'last_page_fetched_tweets' => '0', 'total_posts_in_system' => '0', 'total_replies_in_system' => '0', 'total_follows_in_system' => '0', 'total_users_in_system' => '0', 'is_archive_loaded_replies' => '0', 'is_archive_loaded_follows' => '0', 'crawler_last_run' => '', 'earliest_reply_in_system' => '', 'api_calls_to_leave_unmade_per_minute' => 2, 'avg_replies_per_day' => '2', 'is_public' => '0', 'is_active' => '0', 'network' => 'facebook'); $this->instance = new Instance($r); $this->fb = new Facebook($THINKTANK_CFG['facebook_api_key'], $THINKTANK_CFG['facebook_api_secret']); }
function setUp() { parent::setUp(); $this->DAO = new OwnerMySQLDAO(); $q = "INSERT INTO tt_owners SET user_name='ThinkTankUser', full_name='ThinkTank J. User', user_email='*****@*****.**', user_activated=0, user_pwd='XXX', activation_code='8888'"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_owners SET user_name='ThinkTankUser1', full_name='ThinkTank J. User1', user_email='*****@*****.**', user_activated=1, user_pwd='YYY'"; PDODAO::$PDO->exec($q); }
function setUp() { parent::setUp(); //Insert test links (not images, not expanded) $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image) VALUES ('http://bit.ly/a5VmbO', '', 0, 1, 0);"; $this->db->exec($q); $crawler = Crawler::getInstance(); $crawler->registerCrawlerPlugin('ExpandURLsPlugin'); }
function setUp() { parent::setUp(); //Insert test data into test table //The default Twitter plugin is inserted by default $q = "INSERT INTO `tt_plugins` (`name` , `folder_name` , `description` , `author` , `homepage` , `version` , `is_active` )\nVALUES ( 'My Test Plugin', 'testplugin', 'Proof of concept plugin', 'Gina Trapani', 'http://thinktankapp.com', '0.01', '0' );"; $this->db->exec($q); $q = "INSERT INTO `tt_plugins` (`name` , `folder_name` , `description` , `author` , `homepage` , `version` , `is_active` )\nVALUES ( 'My Test Plugin Activated', 'testpluginact', 'Proof of concept plugin', 'Gina Trapani', 'http://thinktankapp.com', '0.01', '1' );"; $this->db->exec($q); }
function setUp() { parent::setUp(); $this->webapp = Webapp::getInstance(); $this->crawler = Crawler::getInstance(); $this->webapp->registerPlugin('twitter', 'TwitterPlugin'); $this->crawler->registerCrawlerPlugin('TwitterPlugin'); $this->webapp->setActivePlugin('twitter'); $this->logger = Logger::getInstance(); }
function setUp() { parent::setUp(); //TODO: Insert test data into post table //$this->db->exec($q); //Add instance_owner $q = "INSERT INTO tt_owner_instances (owner_id, instance_id) VALUES (1, 1)"; $this->db->exec($q); //Insert test data into test table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (13, 'ev', 'Ev Williams', 'avatar.jpg', '1/1/2005');"; $this->db->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (18, 'shutterbug', 'Shutter Bug', 'avatar.jpg', 0, 10);"; $this->db->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (19, 'linkbaiter', 'Link Baiter', 'avatar.jpg', 0, 10);"; $this->db->exec($q); //Make public $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (13, 'ev', 1);"; $this->db->exec($q); $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (18, 'shutterbug', 1);"; $this->db->exec($q); $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (19, 'linkbaiter', 1);"; $this->db->exec($q); //Add a bunch of posts $counter = 0; while ($counter < 40) { $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$counter}, 13, 'ev', 'Ev Williams', 'avatar.jpg', 'This is post {$counter}', 'web', '2006-01-01 00:{$pseudo_minute}:00', " . rand(0, 4) . ", 5);"; $this->db->exec($q); $counter++; } //Add some photo posts $counter = 0; while ($counter < 40) { $post_id = $counter + 40; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$post_id}, 18, 'shutterbug', 'Shutter Bug', 'avatar.jpg', 'This is image post {$counter}', 'web', '2006-01-02 00:{$pseudo_minute}:00', 0, 0);"; $this->db->exec($q); $q = "INSERT INTO tt_links (url, expanded_url, title, clicks, post_id, is_image) VALUES ('http://example.com/" . $counter . "', 'http://example.com/" . $counter . ".jpg', '', 0, {$post_id}, 1);"; $this->db->exec($q); $counter++; } //Add some link posts $counter = 0; while ($counter < 40) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$post_id}, 19, 'linkbaiter', 'Link Baiter', 'avatar.jpg', 'This is link post {$counter}', 'web', '2006-03-01 00:{$pseudo_minute}:00', 0, 0);"; $this->db->exec($q); $q = "INSERT INTO tt_links (url, expanded_url, title, clicks, post_id, is_image) VALUES ('http://example.com/" . $counter . "', 'http://example.com/" . $counter . ".html', 'Link {$counter}', 0, {$post_id}, 0);"; $this->db->exec($q); $counter++; } }
function setUp() { parent::setUp(); // test table for our test dao $test_table_sql = 'CREATE TABLE tt_test_table(' . 'id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,' . 'test_name varchar(20),' . 'test_id int(11),' . 'unique key test_id_idx (test_id)' . ')'; $this->db->exec($test_table_sql); //some test data as well $q = sprintf("INSERT INTO tt_test_table (test_name, test_id) VALUES ('name%s', %d)", 1, 1); for ($i = 2; $i <= 20; $i++) { $q .= sprintf(",('name%s', %d)", $i, $i); } $this->db->exec($q); }
function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); //insert test users $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (36823, 'anildash', 'Anil Dash', 'avatar.jpg', '2007-01-01');"; $this->db->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (930061, 'ginatrapani', 'Gina Trapani', 'avatar.jpg', '2007-01-01');"; $this->db->exec($q); //insert test follow $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (930061, 36823, '2006-01-08 23:54:41');"; $this->db->exec($q); }
function setUp() { parent::setUp(); $test_table_sql = 'CREATE TABLE tt_test_table(' . 'id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,' . 'test_name varchar(20),' . 'test_id int(11),' . 'unique key test_id_idx (test_id)' . ')'; $this->db->exec($test_table_sql); $q = sprintf("INSERT INTO tt_test_table (test_name, test_id) VALUES ('name%s', %d)", 1, 1); for ($i = 2; $i <= 20; $i++) { $q .= sprintf(",('name%s', %d)", $i, $i); } $this->db->exec($q); // Insert test data into test user table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar) VALUES (12, 'mary', 'Mary Jane', 'avatar.jpg');"; $this->db->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar) VALUES (13, 'sweetmary', 'Sweet Mary Jane', 'avatar.jpg');"; $this->db->exec($q); }
function setUp() { parent::setUp(); $this->DAO = new InstanceMySQLDAO(); $q = "INSERT INTO tt_instances "; $q .= "(`network_user_id`, `network_username`, `network`, "; $q .= "`network_viewer_id`, `crawler_last_run`, `is_active`) VALUES "; $q .= "(10 , 'jack', 'twitter', 10, '1988-01-20 12:00:00', 1), "; $q .= "(12, 'jill', 'twitter', 12, '2010-01-20 12:00:00', 1), "; $q .= "(13 , 'stuart', 'twitter', 13, '2010-01-01 12:00:00', 0), "; $q .= "(15 , 'Jillian Dickerson', 'facebook', 15, '2010-01-01 12:00:01', 1), "; $q .= "(16 , 'Paul Clark', 'facebook', 16, '2010-01-01 12:00:02', 0) "; // $q .= "(17 , 'Jillian Micheals', 'facebook', 15, '2010-01-01 12:00:01', 1) "; PDODAO::$PDO->exec($q); $q = "INSERT INTO `tt_owner_instances` (`owner_id` , `instance_id`) "; $q .= "VALUES ('2', '1'), ('2', '2');"; PDODAO::$PDO->exec($q); }
function setUp() { parent::setUp(); //Add instance_owner $q = "INSERT INTO tt_owner_instances (owner_id, instance_id) VALUES (1, 1)"; $this->db->exec($q); //Insert test data into test table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (13, 'ev', 'Ev Williams', 'avatar.jpg', '1/1/2005');"; $this->db->exec($q); //Make public $q = "INSERT INTO tt_instances (id, network_user_id, network_username, is_public) VALUES (1, 13, 'ev', 1);"; $this->db->exec($q); //Add a bunch of posts $counter = 0; while ($counter < 40) { $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$counter}, 13, 'ev', 'Ev Williams', 'avatar.jpg', 'This is post {$counter}', 'web', '2006-01-01 00:{$pseudo_minute}:00', " . rand(0, 4) . ", 5);"; $this->db->exec($q); $counter++; } }
function setUp() { parent::setUp(); //Insert test data into test table $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar) VALUES (12, 'jack', 'Jack Dorsey', 'avatar.jpg');"; $this->db->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (13, 'ev', 'Ev Williams', 'avatar.jpg', '1/1/2005');"; $this->db->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected) VALUES (16, 'private', 'Private Poster', 'avatar.jpg', 1);"; $this->db->exec($q); $q = "INSERT INTO tt_user_errors (user_id, error_code, error_text, error_issued_to_user_id) VALUES (15, 404, 'User not found', 13);"; $this->db->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 12, '1/1/2006');"; $this->db->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 14, '1/1/2006');"; $this->db->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 15, '1/1/2006');"; $this->db->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (13, 16, '1/1/2006');"; $this->db->exec($q); $q = "INSERT INTO tt_follows (user_id, follower_id, last_seen) VALUES (16, 12, '1/1/2006');"; $this->db->exec($q); }
/** * Add test post to database */ function setUp() { parent::setUp(); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES (1001, 13, 'ev', 'Ev Williams', 'avatar.jpg', 'This is a test post', 'web', '2006-01-01 00:05:00', " . rand(0, 4) . ", 5);"; $this->db->exec($q); }
function setUp() { parent::setUp(); }
function setUp() { parent::setUp(); $this->logger = Logger::getInstance(); }
function setUp() { parent::setUp(); $this->DAO = new PostMySQLDAO(); $q = "INSERT INTO tt_owner_instances (owner_id, instance_id) VALUES (1, 1)"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, last_updated) VALUES (13, 'ev', 'Ev Williams', 'avatar.jpg', '1/1/2005');"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (18, 'shutterbug', 'Shutter Bug', 'avatar.jpg', 0, 10);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (19, 'linkbaiter', 'Link Baiter', 'avatar.jpg', 0, 70);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (20, 'user1', 'User 1', 'avatar.jpg', 0, 90);"; PDODAO::$PDO->exec($q); //protected user $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (21, 'user2', 'User 2', 'avatar.jpg', 1, 80);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (22, 'quoter', 'Quotables', 'avatar.jpg', 0, 80);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (23, 'user3', 'User 3', 'avatar.jpg', 0, 100);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_users (user_id, user_name, full_name, avatar, is_protected, follower_count) VALUES (24, 'notonpublictimeline', 'Not on Public Timeline', 'avatar.jpg', 1, 100);"; PDODAO::$PDO->exec($q); //Make public $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (13, 'ev', 1);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (18, 'shutterbug', 1);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (19, 'linkbaiter', 1);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (23, 'user3', 1);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_instances (network_user_id, network_username, is_public) VALUES (24, 'notonpublictimeline', 0);"; PDODAO::$PDO->exec($q); //Add straight text posts $counter = 0; while ($counter < 40) { $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$counter}, 13, 'ev', 'Ev Williams', 'avatar.jpg', 'This is post {$counter}', 'web', '2006-01-01 00:{$pseudo_minute}:00', " . rand(0, 4) . ", 5);"; PDODAO::$PDO->exec($q); $counter++; } //Add photo posts from Flickr $counter = 0; while ($counter < 40) { $post_id = $counter + 40; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$post_id}, 18, 'shutterbug', 'Shutter Bug', 'avatar.jpg', 'This is image post {$counter}', 'Flickr', '2006-01-02 00:{$pseudo_minute}:00', 0, 0);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_links (url, expanded_url, title, clicks, post_id, is_image) VALUES ('http://example.com/" . $counter . "', 'http://example.com/" . $counter . ".jpg', '', 0, {$post_id}, 1);"; PDODAO::$PDO->exec($q); $counter++; } //Add link posts $counter = 0; while ($counter < 40) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$post_id}, 19, 'linkbaiter', 'Link Baiter', 'avatar.jpg', 'This is link post {$counter}', 'web', '2006-03-01 00:{$pseudo_minute}:00', 0, 0);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_links (url, expanded_url, title, clicks, post_id, is_image) VALUES ('http://example.com/" . $counter . "', 'http://example.com/" . $counter . ".html', 'Link {$counter}', 0, {$post_id}, 0);"; PDODAO::$PDO->exec($q); $counter++; } //Add mentions $counter = 0; while ($counter < 10) { $post_id = $counter + 120; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); if ($counter / 2 == 0) { $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$post_id}, 20, 'user1', 'User 1', 'avatar.jpg', 'Hey @ev and @jack thanks for founding Twitter post {$counter}', 'web', '2006-03-01 00:{$pseudo_minute}:00', 0, 0);"; } else { $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES ({$post_id}, 21, 'user2', 'User 2', 'avatar.jpg', 'Hey @ev and @jack should fix Twitter - post {$counter}', 'web', '2006-03-01 00:{$pseudo_minute}:00', 0, 0);"; } PDODAO::$PDO->exec($q); $counter++; } //Add replies to specific post $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_post_id) VALUES (131, 20, 'user1', 'User 1', 'avatar.jpg', '@shutterbug Nice shot!', 'web', '2006-03-01 00:00:00', 0, 0, 41);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_post_id) VALUES (132, 21, 'user2', 'User 2', 'avatar.jpg', '@shutterbug Nice shot!', 'web', '2006-03-01 00:00:00', 0, 0, 41);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_post_id) VALUES (133, 19, 'linkbaiter', 'Link Baiter', 'avatar.jpg', '@shutterbug This is a link post reply http://example.com/', 'web', '2006-03-01 00:00:00', 0, 0, 41);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_links (url, expanded_url, title, clicks, post_id, is_image) VALUES ('http://example.com/', 'http://example.com/expanded-link.html', 'Link 1', 0, 133, 0);"; PDODAO::$PDO->exec($q); //Add retweets of a specific post //original post $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache) VALUES (134, 22, 'quoter', 'Quoter of Quotables', 'avatar.jpg', 'Be liberal in what you accept and conservative in what you send', 'web', '2006-03-01 00:00:00', 0, 0);"; PDODAO::$PDO->exec($q); //retweet 1 $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_retweet_of_post_id) VALUES (135, 20, 'user1', 'User 1', 'avatar.jpg', 'RT @quoter Be liberal in what you accept and conservative in what you send', 'web', '2006-03-01 00:00:00', 0, 0, 134);"; PDODAO::$PDO->exec($q); //retweet 2 $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_retweet_of_post_id) VALUES (136, 21, 'user2', 'User 2', 'avatar.jpg', 'RT @quoter Be liberal in what you accept and conservative in what you send', 'web', '2006-03-01 00:00:00', 0, 0, 134);"; PDODAO::$PDO->exec($q); //retweet 3 $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_retweet_of_post_id) VALUES (137, 19, 'linkbaiter', 'Link Baiter', 'avatar.jpg', 'RT @quoter Be liberal in what you accept and conservative in what you send', 'web', '2006-03-01 00:00:00', 0, 0, 134);"; PDODAO::$PDO->exec($q); //Add reply back $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_user_id, in_reply_to_post_id) VALUES (138, 18, 'shutterbug', 'Shutterbug', 'avatar.jpg', '@user2 Thanks!', 'web', '2006-03-01 00:00:00', 0, 0, 21, 132);"; PDODAO::$PDO->exec($q); //Add user exchange $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_user_id) VALUES (139, 20, 'user1', 'User 1', 'avatar.jpg', '@ev When will Twitter have a business model?', 'web', '2006-03-01 00:00:00', 0, 0, 13);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_user_id, in_reply_to_post_id) VALUES (140, 13, 'ev', 'Ev Williams', 'avatar.jpg', '@user1 Soon....', 'web', '2006-03-01 00:00:00', 0, 0, 20, 139);"; PDODAO::$PDO->exec($q); //Add posts replying to post not in the system $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_user_id, in_reply_to_post_id) VALUES (141, 23, 'user3', 'User 3', 'avatar.jpg', '@user4 I\\'m replying to a post not in the TT db', 'web', '2006-03-01 00:00:00', 0, 0, 20, 150);"; PDODAO::$PDO->exec($q); $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date, mention_count_cache, retweet_count_cache, in_reply_to_user_id, in_reply_to_post_id) VALUES (142, 23, 'user3', 'User 3', 'avatar.jpg', '@user4 I\\'m replying to another post not in the TT db', 'web', '2006-03-01 00:00:00', 0, 0, 20, 151);"; PDODAO::$PDO->exec($q); //Add post by instance not on public timeline $q = "INSERT INTO tt_posts (post_id, author_user_id, author_username, author_fullname, author_avatar, post_text, source, pub_date) VALUES (143, 24, 'notonpublictimeline', 'Not on public timeline', 'avatar.jpg', 'This post should not be on the public timeline', 'web', '2006-03-01 00:00:00');"; PDODAO::$PDO->exec($q); }
/** * Constructs a database and populates it. */ function setUp() { parent::setUp(); $this->DAO = new LinkMySQLDAO(); //Insert test links (not images, not expanded) $counter = 0; while ($counter < 40) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image) "; $q .= " VALUES ('http://example.com/" . $counter . "', 'Link {$counter}', 0, {$post_id}, 0);"; PDODAO::$PDO->exec($q); $counter++; } //Insert test links (images from Flickr, not expanded) $counter = 0; while ($counter < 5) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image) "; $q .= "VALUES ('http://flic.kr/p/" . $counter . "', 'Link {$counter}', 0, {$post_id}, 1);"; PDODAO::$PDO->exec($q); $counter++; } //Insert test links with errors (images from Flickr, not expanded) $counter = 0; while ($counter < 5) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image, error) "; $q .= "VALUES ('http://flic.kr/p/" . $counter . "', 'Link {$counter}', 0, {$post_id}, 1, "; $q .= "'Generic test error message, Photo not found');"; PDODAO::$PDO->exec($q); $counter++; } //Insert several of the same shortened link $counter = 0; while ($counter < 5) { $post_id = $counter + 80; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_links (url, title, clicks, post_id, is_image, error) "; $q .= "VALUES ('http://bit.ly/beEEfs', 'Link {$counter}', 0, {$post_id}, 1, '');"; $this->db->exec($q); $counter++; } //Insert several posts $counter = 0; while ($counter < 5) { $post_id = $counter + 80; $user_id = $counter * 5 + 2; $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT); $q = "INSERT INTO tt_posts ( "; $q .= " post_id, author_user_id, author_username, author_fullname "; $q .= " ) "; $q .= "VALUES ('{$post_id}', {$user_id}, 'user{$counter}', 'User{$counter} Name{$counter}' "; $q .= " );"; $this->db->exec($q); $counter++; } $q = "INSERT INTO tt_follows ("; $q .= " follower_id, user_id, active "; $q .= " ) "; $q .= " VALUES "; $q .= " (2, 7, 1), "; $q .= " (2, 22, 1), "; $q .= " (2, 17, 1), "; $q .= " (2, 12, 0), "; $q .= " (27, 2, 1), "; $q .= " (18, 22, 0), "; $q .= " (12, 22, 1) "; $this->db->exec($q); }