public function testConfigNotSet() { $plugin_options_dao = DAOFactory::getDAO("PluginOptionDAO"); PluginOptionMySQLDAO::$cached_options = array(); $this->simulateLogin('*****@*****.**'); $owner_dao = DAOFactory::getDAO('OwnerDAO'); $owner = $owner_dao->getByEmail(Session::getLoggedInUser()); $controller = new FacebookPluginConfigurationController($owner); $results = $controller->go(); $v_mgr = $controller->getViewManager(); //@TODO Figure out why API keys are not set here in the test, but they are in the controller $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'), 'Please set your Facebook API Key and Application Secret.'); }
public function testOfCachedOptions() { # init our dao $dao = new PluginOptionMySQLDAO(); $builder1 = $this->buildOptions(1, 'test name', 'test option'); $insert_id1 = $builder1->columns['last_insert_id']; $builder2 = $this->buildOptions(2, 'test name2', 'test option2'); $insert_id2 = $builder2->columns['last_insert_id']; $builder3 = $this->buildOptions(2, 'test name3', 'test option3'); $insert_id3 = $builder3->columns['last_insert_id']; // gets all options if no plugin_id passed $options = $dao->getOptions(null, true); $this->assertNotNull($options); $this->assertEqual(3, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 1); $this->assertEqual($options[1]->plugin_id, 2); $this->assertEqual($options[2]->plugin_id, 2); // in the cache $options = PluginOptionMySQLDAO::$cached_options; $options = $options['all']; $this->assertNotNull($options); $this->assertEqual(3, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 1); $this->assertEqual($options[1]->plugin_id, 2); $this->assertEqual($options[2]->plugin_id, 2); // gets all options if no plugin_id passed (cached) $options = $dao->getOptions(null, true); $this->assertNotNull($options); $this->assertEqual(3, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 1); $this->assertEqual($options[1]->plugin_id, 2); $this->assertEqual($options[2]->plugin_id, 2); // gets all options if plugin_id passed $options = $dao->getOptions('twitter', true); $this->assertNotNull($options); $this->assertEqual(1, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 1); $this->assertEqual($options[0]->id, 1); //in the cache? $options = PluginOptionMySQLDAO::$cached_options; $options = $options['twitterid']; $this->assertNotNull($options); $this->assertEqual(1, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 1); $this->assertEqual($options[0]->id, 1); //cached? $options = $dao->getOptions('twitter', true); $this->assertNotNull($options); $this->assertEqual(1, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 1); $this->assertEqual($options[0]->id, 1); }
public function testOfGetOptions() { $plugin_builder1 = FixtureBuilder::build('plugins', array('id'=>'2', 'folder_name'=>'test_plugin')); $plugin_builder2 = FixtureBuilder::build('plugins', array('id'=>'3', 'folder_name'=>'test_plugin1')); # init our dao $dao = new PluginOptionMySQLDAO(); $builder1 = $this->buildOptions(1, 'test name', 'test option'); $insert_id1 = $builder1->columns[ 'last_insert_id' ]; $builder2 = $this->buildOptions(2, 'test name2', 'test option2'); $insert_id2 = $builder2->columns[ 'last_insert_id' ]; $builder3 = $this->buildOptions(2, 'test name3', 'test option3'); $insert_id3 = $builder3->columns[ 'last_insert_id' ]; // bad plugin id $this->assertNull( $dao->getOptions(-99) ); // gets all options if plugin_id passed $options = $dao->getOptions('twitter'); $this->assertNotNull( $options ); $this->assertEqual(1, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 1); $this->assertEqual($options[0]->id, 2); // gets all options if plugin_id passed one more time $options = $dao->getOptions('test_plugin'); $this->assertNotNull( $options ); $this->assertEqual(2, count($options)); $this->assertIsA($options[0], 'PluginOption'); $this->assertEqual($options[0]->plugin_id, 2); $this->assertEqual($options[0]->id, 3); $this->assertIsA($options[1], 'PluginOption'); $this->assertEqual($options[1]->plugin_id, 2); $this->assertEqual($options[1]->id, 4); }
public function testConfigNotSet() { $plugin_options_dao = DAOFactory::getDAO("PluginOptionDAO"); PluginOptionMySQLDAO::$cached_options = array(); $this->simulateLogin('*****@*****.**'); $owner_dao = DAOFactory::getDAO('OwnerDAO'); $owner = $owner_dao->getByEmail(Session::getLoggedInUser()); $controller = new FacebookPluginConfigurationController($owner); $results = $controller->go(); $v_mgr = $controller->getViewManager(); $info = $v_mgr->getTemplateDataItem('info_msgs'); $this->assertEqual($info['setup'], 'Please complete plugin setup to start using it.'); $this->debug(Utils::varDumpToString($info)); //assert configuration URL is showing $site_url = $v_mgr->getTemplateDataItem('thinkup_site_url'); $this->assertEqual($site_url, Utils::getApplicationURL()); }
public function testGetUserProfileWith403Error() { $builders = $this->buildPluginOptions(); $config = Config::getInstance(); $config->setValue('site_root_path', '/'); $plugin_options_dao = DAOFactory::getDAO("PluginOptionDAO"); PluginOptionMySQLDAO::$cached_options = array(); $builders[] = FixtureBuilder::build('owners', array('email' => '*****@*****.**', 'user_activated' => 1)); $this->simulateLogin('*****@*****.**'); $owner_dao = DAOFactory::getDAO('OwnerDAO'); $owner = $owner_dao->getByEmail(Session::getLoggedInUser()); $controller = new GooglePlusPluginConfigurationController($owner); $_GET['code'] = 'test-google-provided-code-user-profile-403-error'; $results = $controller->go(); $v_mgr = $controller->getViewManager(); $this->assertEqual($v_mgr->getTemplateDataItem('success_msg'), ''); $msgs = $v_mgr->getTemplateDataItem('error_msgs'); $this->assertEqual($msgs['authorization'], 'Oops! Looks like Google+ API access isn\'t turned on. ' . '<a href="http://code.google.com/apis/console#access">In the Google APIs console</a>, in Services, flip the ' . 'Google+ API Status switch to \'On\' and try again.'); $this->debug(Utils::varDumpToString($msgs)); }
public function testGetOAuthTokensWithError() { // Build the plugin options $builders = $this->buildPluginOptions(); // Get an instance $config = Config::getInstance(); // Set the root path $config->setValue('site_root_path', '/'); // Get a plugin option DAO $plugin_options_dao = DAOFactory::getDAO("PluginOptionDAO"); // PluginOptionMySQLDAO::$cached_options = array(); // Build a owner $builders[] = FixtureBuilder::build('owners', array('email' => '*****@*****.**', 'user_activated' => 1)); // Log the owner in $this->simulateLogin('*****@*****.**'); // Get a owner DAO $owner_dao = DAOFactory::getDAO('OwnerDAO'); // Get the logged in owners email address $owner = $owner_dao->getByEmail(Session::getLoggedInUser()); // Create a new controller for this user $controller = new FoursquarePluginConfigurationController($owner); // Set the return code from foursquare to anything not valid $_GET['code'] = 'error5dn'; // Check the user is told theres a problem $results = $controller->go(); $v_mgr = $controller->getViewManager(); $this->assertEqual($v_mgr->getTemplateDataItem('success_msg'), ''); $msgs = $v_mgr->getTemplateDataItem('error_msgs'); $this->assertEqual($msgs['authorization'], 'Oops! Something went wrong while obtaining OAuth tokens.' . ' foursquare says "foursquare_error_text." Please double-check your settings and try again.'); }
public function testGetUserProfileWithNoGooglePlusID() { $builders = $this->buildPluginOptions(); $config = Config::getInstance(); $config->setValue('site_root_path', '/'); $plugin_options_dao = DAOFactory::getDAO("PluginOptionDAO"); PluginOptionMySQLDAO::$cached_options = array(); $builders[] = FixtureBuilder::build('owners', array('email' => '*****@*****.**', 'user_activated' => 1)); $this->simulateLogin('*****@*****.**'); $owner_dao = DAOFactory::getDAO('OwnerDAO'); $owner = $owner_dao->getByEmail(Session::getLoggedInUser()); $controller = new YouTubePluginConfigurationController($owner); $_GET['code'] = 'nogplus'; $results = $controller->go(); $v_mgr = $controller->getViewManager(); $this->assertEqual($v_mgr->getTemplateDataItem('success_msg'), ''); $msgs = $v_mgr->getTemplateDataItem('error_msgs'); $this->assertEqual($msgs['authorization'], 'You don\'t have a Google+ ID associated with your YouTube account,' . " go to YouTube and link your Google+ account to your YouTube account to use this plugin. For more informatio" . "n click <a href=https://www.thinkup.com/docs/userguide/settings/plugins/youtube.html>here</a>"); }