public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('google+', 'TwitterRealtimePlugin');
     $webapp->setActivePlugin('google+');
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('flickr', 'ExpandURLsPlugin');
     //Add owner
     $q = "INSERT INTO tu_owners SET id=1, full_name='ThinkUp J. User', email='*****@*****.**',\n        is_activated=1, pwd='XXX', activation_code='8888'";
     $this->testdb_helper->runSQL($q);
     //Add instance_owner
     $q = "INSERT INTO tu_owner_instances (owner_id, instance_id) VALUES (1, 1)";
     $this->testdb_helper->runSQL($q);
     //Insert test data into test table
     $q = "INSERT INTO tu_users (user_id, user_name, full_name, avatar, last_updated) VALUES (13, 'ev',\n        'Ev Williams', 'avatar.jpg', '1/1/2005');";
     $this->testdb_helper->runSQL($q);
     //Make public
     $q = "INSERT INTO tu_instances (id, network_user_id, network_username, is_public) VALUES (1, 13, 'ev', 1);";
     $this->testdb_helper->runSQL($q);
     //Add a bunch of posts
     $counter = 0;
     while ($counter < 40) {
         $pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT);
         $q = "INSERT INTO tu_posts (post_id, author_user_id, author_username, author_fullname, author_avatar,\n            post_text, source, pub_date, reply_count_cache, retweet_count_cache) VALUES ({$counter}, 13, 'ev', \n            'Ev Williams', 'avatar.jpg', 'This is post {$counter}', 'web', '2006-01-01 00:{$pseudo_minute}:00', " . rand(0, 4) . ", 5);";
         $this->testdb_helper->runSQL($q);
         $counter++;
     }
 }
 /**
  * Set up
  * Initializes Config and Webapp objects
  */
 function setUp()
 {
     $config = Config::getInstance();
     $webapp = Webapp::getInstance();
     $crawler = Crawler::getInstance();
     parent::setUp();
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('twitter', 'TwitterPlugin');
     $webapp->registerPlugin('facebook', 'FacebookPlugin');
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('google+', 'HelloThinkUpPlugin');
     $webapp->setActivePlugin('google+');
 }
 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++;
     }
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('InsightsGenerator', 'InsightsGeneratorPlugin');
     $webapp->setActivePlugin('InsightsGenerator');
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('twitter', 'TwitterPlugin');
     $this->builders = self::buildData();
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('googleplus', 'GooglePlusPlugin');
     $_SERVER['SERVER_NAME'] = 'dev.thinkup.com';
 }
 /**
  * Setup
  */
 public function setUp()
 {
     parent::setUp();
     $this->builders = array();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('facebook', 'FacebookPlugin');
     //Add owner
     $owner_builder = FixtureBuilder::build('owners', array('id' => 1, 'full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 1));
     array_push($this->builders, $owner_builder);
     //Add instance
     $instance_builder = FixtureBuilder::build('instances', array('id' => 1, 'network_user_id' => 606837591, 'network_username' => 'Gina Trapani', 'network' => 'facebook', 'is_active' => 1));
     array_push($this->builders, $instance_builder);
     //Add owner instance_owner
     $owner_instance_builder = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 1, 'oauth_access_token' => 'faux-access-token1'));
     array_push($this->builders, $owner_instance_builder);
     //Add second owner
     $owner2_builder = FixtureBuilder::build('owners', array('id' => 2, 'full_name' => 'ThinkUp J. User 2', 'email' => '*****@*****.**', 'is_activated' => 1));
     array_push($this->builders, $owner2_builder);
     //Add second instance
     $instance2_builder = FixtureBuilder::build('instances', array('id' => 2, 'network_user_id' => 668406218, 'network_username' => 'Penelope Caridad', 'network' => 'facebook', 'is_active' => 1));
     array_push($this->builders, $instance2_builder);
     //Add second owner instance_owner
     $owner_instance2_builder = FixtureBuilder::build('owner_instances', array('owner_id' => 2, 'instance_id' => 2, 'oauth_access_token' => 'faux-access-token2'));
     array_push($this->builders, $owner_instance2_builder);
     $_SERVER['SERVER_NAME'] = 'dev.thinkup.com';
     $_SERVER['HTTP_HOST'] = 'http://';
     $_SERVER['REQUEST_URI'] = '';
 }
 public function adminControl()
 {
     if (!$this->is_missing_param) {
         // verify CSRF token
         $this->validateCSRFToken();
         $is_active = $_GET["a"] != 1 ? false : true;
         $plugin_dao = DAOFactory::getDAO('PluginDAO');
         $result = $plugin_dao->setActive($_GET["pid"], $is_active);
         if ($result > 0) {
             $plugin_folder = $plugin_dao->getPluginFolder($_GET["pid"]);
             $webapp = Webapp::getInstance();
             try {
                 $plugin_class_name = $webapp->getPluginObject($plugin_folder);
                 $p = new $plugin_class_name();
                 if ($is_active) {
                     $p->activate();
                 } else {
                     $p->deactivate();
                 }
             } catch (Exception $e) {
                 //plugin object isn't registered, do nothing
                 //echo $e->getMessage();
             }
         }
         $this->addToView('result', $result);
         $this->view_mgr->clear_all_cache();
     }
     return $this->generateView();
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('twitter', 'TwitterPlugin');
     $this->config = Config::getInstance();
 }
 /**
  * Load the view with required variables
  */
 private function loadView()
 {
     $webapp = Webapp::getInstance();
     if ($this->view_name == 'default') {
         $this->loadDefaultDashboard();
     } else {
         $menu_item = $webapp->getDashboardMenuItem($this->view_name, $this->instance);
         if (isset($menu_item)) {
             $this->addToView('data_template', $menu_item->view_template);
             $this->addToView('display', $this->view_name);
             $this->addToView('header', $menu_item->name);
             $this->addToView('description', $menu_item->description);
             $this->addToView('parent', $menu_item->parent);
             $this->setPageTitle($this->instance->network_username . ' on ' . ucfirst($this->instance->network));
             $page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1;
             foreach ($menu_item->datasets as $dataset) {
                 if (array_search('#page_number#', $dataset->method_params) !== false) {
                     //there's paging
                     $this->addToView('next_page', $page + 1);
                     $this->addToView('last_page', $page - 1);
                 }
                 $this->addToView($dataset->name, $dataset->retrieveDataset($page));
                 if (Session::isLoggedIn() && $dataset->isSearchable()) {
                     $view_name = 'is_searchable';
                     $this->addToView($view_name, true);
                 }
                 $this->view_mgr->addHelp($this->view_name, $dataset->getHelp());
             }
         } else {
             $this->loadDefaultDashboard();
         }
     }
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('InsightsGenerator', 'InsightsGeneratorPlugin');
     $_SERVER['SERVER_NAME'] = 'dev.thinkup.com';
 }
 public function  setUp() {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $crawler = Crawler::getInstance();
     $webapp->registerPlugin('flickrthumbnails', 'FlickrThumbnailsPlugin');
     $crawler->registerCrawlerPlugin('FlickrThumbnailsPlugin');
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('expandurls', 'ExpandURLsPlugin');
     $this->builders = self::buildData();
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('geoencoder', 'GeoEncoderPlugin');
     $_SERVER['SERVER_NAME'] = 'dev.thinkup.com';
     $_SERVER['HTTP_HOST'] = 'dev.thinkup.com';
 }
 public function setUp() {
     parent::setUp();
     $this->webapp = Webapp::getInstance();
     $this->webapp->registerPlugin('geoencoder', 'GeoEncoderPlugin');
     $this->webapp->registerPlugin('twitter', 'TwitterPlugin');
     $crawler = Crawler::getInstance();
     $crawler->registerCrawlerPlugin('GeoEncoderPlugin');
 }
Example #19
0
 /**
  * Test registerPlugin when plugin object does not have the right methods available
  */
 public function testWebappRegisterPluginWithoutWebappInterfaceImplemented()
 {
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('hellothinktank', "HelloThinkTankPlugin");
     $webapp->setActivePlugin('hellothinktank');
     $this->expectException(new Exception("The HelloThinkTankPlugin object does not have a getChildTabsUnderPosts method."));
     $webapp->getChildTabsUnderPosts(null);
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('twitter', 'TwitterPlugin');
     $this->builders = self::buildData();
     $_SERVER['HTTP_HOST'] = "mytesthost";
     $_SERVER['SERVER_NAME'] = 'dev.thinkup.com';
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('twitter', 'TwitterPlugin');
     //Add owner
     $q = "INSERT INTO tu_owners SET id=1, full_name='ThinkUp J. User', email='*****@*****.**', is_activated=1,\n        pwd='XXX', activation_code='8888'";
     $this->db->exec($q);
 }
 public 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();
 }
 public function setUp()
 {
     parent::setUp();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('twitter', 'TwitterPlugin');
     $session = new Session();
     $cryptpass = $session->pwdcrypt("secretpassword");
     $owner = array('id' => 1, 'email' => '*****@*****.**', 'pwd' => $cryptpass, 'is_activated' => 1);
     $this->builder1 = FixtureBuilder::build('owners', $owner);
     $instance = array('id' => 1);
     $this->builder2 = FixtureBuilder::build('instances', $instance);
     $owner_instance = array('owner_id' => 1, 'instance_id' => 1);
     $this->builder3 = FixtureBuilder::build('owner_instances', $owner_instance);
 }
 /**
  * @return str Rendered view markup
  * @TODO Throw an Insufficient privileges Exception when owner doesn't have access to an instance
  */
 public function authControl()
 {
     if (!$this->is_missing_param) {
         $instance_dao = DAOFactory::getDAO('InstanceDAO');
         $instance = $instance_dao->getByUsernameOnNetwork($_GET['u'], $_GET['n']);
         if (isset($instance)) {
             $webapp = Webapp::getInstance();
             $webapp->setActivePlugin($instance->network);
             $tab = $webapp->getTab($_GET['d'], $instance);
             $this->setViewTemplate($tab->view_template);
         } else {
             $continue = false;
         }
     } else {
         $continue = false;
     }
     if ($this->shouldRefreshCache()) {
         $owner_dao = DAOFactory::getDAO('OwnerDAO');
         $owner = $owner_dao->getByEmail($this->getLoggedInUser());
         $continue = true;
         if (!$this->is_missing_param) {
             $instance = $instance_dao->getByUsernameOnNetwork($_GET['u'], $_GET['n']);
             if (isset($instance)) {
                 $ownerinstance_dao = DAOFactory::getDAO('OwnerInstanceDAO');
                 if (!$ownerinstance_dao->doesOwnerHaveAccess($owner, $instance)) {
                     $this->addErrorMessage('Insufficient privileges. <a href="/">Back</a>.');
                     $continue = false;
                 } else {
                     $this->addToView('i', $instance);
                 }
             } else {
                 $this->addErrorMessage($_GET['u'] . " is not configured.");
                 $continue = false;
             }
         } else {
             $continue = false;
         }
         if ($continue) {
             $this->addToView('display', $tab->short_name);
             $this->addToView('header', $tab->name);
             $this->addToView('description', $tab->description);
             foreach ($tab->datasets as $dataset) {
                 $this->addToView($dataset->name, $dataset->retrieveDataset());
             }
         } else {
             $this->setViewTemplate('inline.view.tpl');
         }
     }
     return $this->generateView();
 }
 /**
  * Set up
  * Initializes Config and Webapp objects, clears $_SESSION, $_POST, $_REQUEST
  */
 public function setUp()
 {
     parent::setUp();
     Loader::register(array(THINKUP_ROOT_PATH . 'tests/', THINKUP_ROOT_PATH . 'tests/classes/', THINKUP_ROOT_PATH . 'tests/fixtures/'));
     $config = Config::getInstance();
     //disable caching for tests
     $config->setValue('cache_pages', false);
     //tests assume profiling is off
     $config->setValue('enable_profiler', false);
     if ($config->getValue('timezone')) {
         date_default_timezone_set($config->getValue('timezone'));
     }
     $webapp = Webapp::getInstance();
     $crawler = Crawler::getInstance();
 }
 public function authControl()
 {
     $webapp = Webapp::getInstance();
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail($this->getLoggedInUser());
     $this->addToView('owner', $owner);
     /* Begin plugin-specific configuration handling */
     if (isset($_GET['p'])) {
         // add config js to header
         $this->addHeaderJavaScript('assets/js/plugin_options.js');
         $active_plugin = $_GET['p'];
         $pobj = $webapp->getPluginObject($active_plugin);
         $p = new $pobj();
         $this->addToView('body', $p->renderConfiguration($owner));
         $profiler = Profiler::getInstance();
         $profiler->clearLog();
     } else {
         $pld = DAOFactory::getDAO('PluginDAO');
         $config = Config::getInstance();
         $installed_plugins = $pld->getInstalledPlugins($config->getValue("source_root_path"));
         $this->addToView('installed_plugins', $installed_plugins);
     }
     /* End plugin-specific configuration handling */
     if (isset($_POST['changepass']) && $_POST['changepass'] == 'Change password' && isset($_POST['oldpass']) && isset($_POST['pass1']) && isset($_POST['pass2'])) {
         $origpass = $owner_dao->getPass($this->getLoggedInUser());
         if (!$this->app_session->pwdCheck($_POST['oldpass'], $origpass)) {
             $this->addErrorMessage("Old password does not match or empty.");
         } elseif ($_POST['pass1'] != $_POST['pass2']) {
             $this->addErrorMessage("New passwords did not match. Your password has not been changed.");
         } elseif (strlen($_POST['pass1']) < 5) {
             $this->addErrorMessage("New password must be at least 5 characters. " . "Your password has not been changed.");
         } else {
             $cryptpass = $this->app_session->pwdcrypt($_POST['pass1']);
             $owner_dao->updatePassword($this->getLoggedInUser(), $cryptpass);
             $this->addSuccessMessage("Your password has been updated.");
         }
     }
     if ($owner->is_admin) {
         $instance_dao = DAOFactory::getDAO('InstanceDAO');
         $owners = $owner_dao->getAllOwners();
         foreach ($owners as $o) {
             $instances = $instance_dao->getByOwner($o, true);
             $o->setInstances($instances);
         }
         $this->addToView('owners', $owners);
     }
     return $this->generateView();
 }
 public function setUp()
 {
     parent::setUp();
     $this->builders = array();
     $webapp = Webapp::getInstance();
     $webapp->registerPlugin('facebook', 'FacebookPlugin');
     $_SERVER['SERVER_NAME'] = 'dev.thinkup.com';
     $_SERVER['HTTP_HOST'] = 'dev.thinkup.com';
     $_SERVER['REQUEST_URI'] = '';
     //Add owners
     $owner_builder = FixtureBuilder::build('owners', array('id' => 1, 'full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 1));
     array_push($this->builders, $owner_builder);
     //Add second owner
     $owner2_builder = FixtureBuilder::build('owners', array('id' => 2, 'full_name' => 'ThinkUp J. User 2', 'email' => '*****@*****.**', 'is_activated' => 1));
     array_push($this->builders, $owner2_builder);
 }
 /**
  * Initialize Config and Webapp objects, clear $_SESSION, $_POST, $_GET, $_REQUEST
  */
 public function setUp()
 {
     parent::setUp();
     Loader::register(array(THINKUP_ROOT_PATH . 'tests/', THINKUP_ROOT_PATH . 'tests/classes/', THINKUP_ROOT_PATH . 'tests/fixtures/'));
     $config = Config::getInstance();
     //disable caching for tests
     $config->setValue('cache_pages', false);
     //tests assume profiling is off
     $config->setValue('enable_profiler', false);
     if ($config->getValue('timezone')) {
         date_default_timezone_set($config->getValue('timezone'));
     }
     $webapp = Webapp::getInstance();
     $crawler = Crawler::getInstance();
     $this->DEBUG = getenv('TEST_DEBUG') !== false ? true : false;
     self::isTestEnvironmentReady();
 }
 public function testMenuItemRegistration()
 {
     $webapp = Webapp::getInstance();
     $logger = Logger::getInstance();
     $pd = DAOFactory::getDAO('PostDAO');
     $instance = new Instance();
     $instance->network_user_id = 1;
     $menus = $webapp->getDashboardMenu($instance);
     $posts_menu = $menus["posts-all"];
     $this->assertEqual(sizeof($menus), 5);
     $post_tab = $menus['posts-all'];
     $this->assertEqual($post_tab->name, "All posts");
     $this->assertEqual($post_tab->description, "All posts");
     $post_tab_datasets = $post_tab->getDatasets();
     $post_tab_dataset = $post_tab_datasets[0];
     $this->assertEqual($post_tab_dataset->name, "gplus_posts");
     $this->assertEqual($post_tab_dataset->dao_name, 'PostDAO');
     $this->assertEqual($post_tab_dataset->dao_method_name, "getAllPosts");
     $post_tab = $menus['posts-mostreplies'];
     $this->assertEqual($post_tab->name, "Most discussed");
     $this->assertEqual($post_tab->description, "Posts with the most comments");
     $post_tab_datasets = $post_tab->getDatasets();
     $post_tab_dataset = $post_tab_datasets[0];
     $this->assertEqual($post_tab_dataset->name, "gplus_posts");
     $this->assertEqual($post_tab_dataset->dao_name, 'PostDAO');
     $this->assertEqual($post_tab_dataset->dao_method_name, "getMostRepliedToPosts");
     $post_tab = $menus['posts-mostplusones'];
     $this->assertEqual($post_tab->name, "Most +1'ed");
     $this->assertEqual($post_tab->description, "Posts with most +1's");
     $post_tab_datasets = $post_tab->getDatasets();
     $post_tab_dataset = $post_tab_datasets[0];
     $this->assertEqual($post_tab_dataset->name, "gplus_posts");
     $this->assertEqual($post_tab_dataset->dao_name, 'PostDAO');
     $this->assertEqual($post_tab_dataset->dao_method_name, "getMostFavedPosts");
     $post_tab = $menus['posts-questions'];
     $this->assertEqual($post_tab->name, "Inquiries");
     $this->assertEqual($post_tab->description, "Inquiries, or posts with a question mark in them");
     $post_tab_datasets = $post_tab->getDatasets();
     $post_tab_dataset = $post_tab_datasets[0];
     $this->assertEqual($post_tab_dataset->name, "gplus_posts");
     $this->assertEqual($post_tab_dataset->dao_name, 'PostDAO');
     $this->assertEqual($post_tab_dataset->dao_method_name, "getAllQuestionPosts");
     $logger->close();
 }
Example #30
0
 /**
  * Test getTab
  */
 public function testGetTab()
 {
     $webapp = Webapp::getInstance();
     $config = Config::getInstance();
     $webapp->registerPlugin('twitter', "TwitterPlugin");
     $webapp->setActivePlugin('twitter');
     $instance = new Instance();
     $instance->network_user_id = 930061;
     $tab = $webapp->getTab('tweets-all', $instance);
     $this->assertIsA($tab, 'WebappTab');
     $this->assertEqual($tab->view_template, Utils::getPluginViewDirectory('twitter') . 'twitter.inline.view.tpl', "Template ");
     $this->assertEqual($tab->short_name, 'tweets-all', "Short name");
     $this->assertEqual($tab->name, 'All', "Name");
     $this->assertEqual($tab->description, 'All tweets', "Description");
     $this->assertIsA($tab->datasets, 'array');
     $this->assertEqual(sizeOf($tab->datasets), 1);
     $tab = $webapp->getTab('nonexistent', $instance);
     $this->assertEqual($tab, null);
 }