public function testReconnectAccount()  {
        $owner_instance_dao = new OwnerInstanceMySQLDAO();
        $instance_dao = new InstanceMySQLDAO();
        $owner_dao = new OwnerMySQLDAO();

        $_GET['p'] = 'facebook';
        $_GET['perms'] = 'offline_access,read_stream,user_likes,user_location,user_website,read_friendlists';
        $_GET['selected_profiles'] = '606837591';
        $_GET['session'] = '{"session_key":"new-faux-access-token","uid":"606837591","expires":0,"secret":'.
        '"itsasecret","access_token":"new-faux-access-token","sig":"siggysigsig"}';

        $options_arry = $this->buildPluginOptions();
        $this->simulateLogin('*****@*****.**', true);
        $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
        $controller = new FacebookPluginConfigurationController($owner, 'facebook');
        $output = $controller->go();

        $v_mgr = $controller->getViewManager();
        $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), "Success! You've reconnected your Facebook ".
        "account.");

        $instance = $instance_dao->getByUserIdOnNetwork('606837591', 'facebook');
        $this->assertTrue(isset($instance));

        $oinstance = $owner_instance_dao->get($owner->id, $instance->id);
        $this->assertTrue(isset($oinstance));
        $this->assertEqual($oinstance->oauth_access_token, 'new-faux-access-token');
    }
Exemplo n.º 2
0
 public function renderConfiguration($owner)
 {
     $controller = new FacebookPluginConfigurationController($owner);
     return $controller->go();
 }
 public function testForDeleteCSRFToken()
 {
     self::buildInstanceData();
     $owner_instance_dao = new OwnerInstanceMySQLDAO();
     $instance_dao = new InstanceMySQLDAO();
     $owner_dao = new OwnerMySQLDAO();
     $options_arry = $this->buildPluginOptions();
     $this->simulateLogin('*****@*****.**', true, true);
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     $controller = new FacebookPluginConfigurationController($owner, 'facebook');
     // add mock page data to view
     $owner_instance_pages = array('123456' => array('id' => '123456', 'network_username' => 'test_username', 'network' => 'facebook'));
     $view = $controller->getViewManager();
     $view->assign('owner_instance_pages', $owner_instance_pages);
     $output = $controller->go();
     // looks for account delete token
     $this->assertPattern('/name="csrf_token" value="' . self::CSRF_TOKEN . '" \\/><!\\-\\- delete account csrf token \\-\\->/', $output);
     // looks for page delete token
     $this->assertPattern('/name="csrf_token" value="' . self::CSRF_TOKEN . '" \\/><!\\-\\- delete page csrf token \\-\\->/', $output);
 }
 public function testOwnerProLevelWith9AccountsConnected()
 {
     self::buildInstanceData();
     // build options data
     $options_array = $this->buildPluginOptions();
     //Add 9 connected Facebok accounts
     $i = 9;
     while ($i > 0) {
         $builders[] = FixtureBuilder::build('instances', array('id' => 10 + $i, 'network_user_id' => 14, 'network_username' => 'zuck', 'is_public' => 1, 'network' => 'facebook'));
         $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 2, 'instance_id' => 10 + $i));
         $i--;
     }
     $config = Config::getInstance();
     $config->setValue('thinkupllc_endpoint', 'http://example.com/user/');
     $this->simulateLogin('*****@*****.**', true);
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     //Set membership_level to Pro
     $owner->membership_level = "Pro";
     $controller = new FacebookPluginConfigurationController($owner, 'facebook');
     $output = $controller->go();
     $this->debug($output);
     // Assert that the Add User button isn't there
     $this->assertNoPattern('/Add a Facebook Account/', $output);
     // Assert that the message about the membership cap is there
     $this->assertPattern('/you’ve connected 10 of 10 accounts to ThinkUp./', $output);
 }
    /**
     * Test config isa admin
     */
    public function testConfigOptionsIsAdmin() {

        // build some options data
        $options_arry = $this->buildPluginOptions();
        $this->simulateLogin('*****@*****.**', true);
        $owner_dao = DAOFactory::getDAO('OwnerDAO');
        $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
        $controller = new TwitterPluginConfigurationController($owner, 'twitter');
        $output = $controller->go();
        // we have a text form element with proper data
        $this->assertPattern('/save options/', $output); // should have no submit option
        $this->assertPattern('/plugin_options_oauth_consumer_secret/', $output); // should have secret option
        $this->assertPattern('/plugin_options_archive_limit/', $output); // should have limit option
        $this->assertPattern('/plugin_options_oauth_consumer_key/', $output); // should have key option
        $this->assertPattern('/var is_admin = true/', $output); // is a js admin

        //app not configured
        $controller = new FacebookPluginConfigurationController($owner, 'facebook');
        $output = $controller->go();
        $this->assertPattern('/var required_values_set = false/', $output); // is not configured
    }
 public function testConfigNotSet()
 {
     //unset FB API keys in Config
     $config = Config::getInstance();
     $config->setValue('facebook_api_key', null);
     $config->setValue('facebook_api_secret', null);
     $api_key = $config->getValue('facebook_api_key');
     $this->assertTrue(!isset($api_key));
     //logged in
     $_SESSION['user'] = '******';
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail($_SESSION['user']);
     $controller = new FacebookPluginConfigurationController($owner);
     $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('error'), 'Please set your Facebook API key and secret in config.inc.php');
 }
 /**
  * Test output
  */
 public function testOutputNoParams()
 {
     //not logged in, no owner set
     $builders = $this->buildPluginOptions();
     $controller = new FacebookPluginConfigurationController(null);
     $output = $controller->go();
     $v_mgr = $controller->getViewManager();
     $config = Config::getInstance();
     $this->assertEqual('You must <a href="' . $config->getValue('site_root_path') . 'session/login.php">log in</a> to do this.', $v_mgr->getTemplateDataItem('errormsg'));
     //logged in
     $this->simulateLogin('*****@*****.**');
     $owner_dao = DAOFactory::getDAO('OwnerDAO');
     $owner = $owner_dao->getByEmail(Session::getLoggedInUser());
     $controller = new FacebookPluginConfigurationController($owner);
     $output = $controller->go();
     $v_mgr = $controller->getViewManager();
     $this->assertIsA($v_mgr->getTemplateDataItem('owner_instances'), 'array', 'Owner instances set');
     $this->assertTrue($v_mgr->getTemplateDataItem('fbconnect_link') != '', 'Authorization link set');
 }