public function tearDown()
 {
     parent::tearDown();
     $this->logger->close();
     // clear options cache
     PluginOptionMySQLDAO::$cached_options = array();
 }
 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 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>");
 }