public function authControl() { $this->app_session->logout(); $controller = new PublicTimelineController(true); $controller->addSuccessMessage("You have successfully logged out."); return $controller->go(); }
function testControlMostReplies() { $_REQUEST["v"] = 'mostreplies'; $controller = new PublicTimelineController(true); $results = $controller->control(); $this->assertTrue(strpos($results, "Posts that have been replied to most often") > 0, "most replies list"); }
/** * Bounce user to public page or to error page. * @TODO bounce back to original action once signed in */ protected function bounce() { if (get_class($this) == 'PrivateDashboardController' || get_class($this) == 'PostController') { $controller = new PublicTimelineController(true); return $controller->go(); } else { $config = Config::getInstance(); throw new Exception('You must <a href="' . $config->getValue('site_root_path') . 'session/login.php">log in</a> to do this.'); } }
public function control() { if ($this->isLoggedIn()) { $this->addToView('logged_in_user', $this->getLoggedInUser()); $this->addToViewCacheKey($this->getLoggedInUser()); return $this->authControl(); } else { //@TODO bounce to sign in page and bounce back to original action once signed in if (get_class($this) == 'PrivateDashboardController') { $controller = new PublicTimelineController(true); return $controller->go(); } else { return "You must be logged in to do this"; } } }
<?php require_once 'init.php'; require_once 'controller/class.PublicTimelineController.php'; $controller = new PublicTimelineController(); echo $controller->go();
public function testControlUserDashboard() { $_GET["u"] = 'ginatrapani'; $_GET["n"] = 'twitter'; $instance_builder = FixtureBuilder::build('instances', array('network_username' => 'ginatrapani', 'network_user_id' => '930061', 'network' => 'twitter', 'is_public' => 1)); $user_builder = FixtureBuilder::build('users', array('user_name' => 'ginatrapani', 'user_id' => '930061', 'network' => 'twitter')); $id = 100; $counter = 0; $builders = array(); while ($counter < 10) { $id += $counter; if ($counter <= 5) { $builders[] = FixtureBuilder::build('posts', array('id' => $id, 'post_id' => 144 + $counter, 'author_user_id' => 930061, 'author_username' => 'ginatrapani', 'pub_date' => '-' . $counter . 'd', 'reply_count_cache' => $counter)); } else { $builders[] = FixtureBuilder::build('posts', array('id' => $id, 'post_id' => 144 + $counter, 'author_user_id' => 930061, 'author_username' => 'ginatrapani', 'pub_date' => '-' . $counter . 'd', 'retweet_count_cache' => $counter)); } $counter++; } //first, add some people $user1_builder = FixtureBuilder::build('users', array('user_name' => 'jack', 'user_id' => '2001', 'network' => 'twitter', 'follower_count' => '10050', 'friend_count' => '10')); $user2_builder = FixtureBuilder::build('users', array('user_name' => 'anildash', 'user_id' => '123456', 'network' => 'twitter', 'follower_count' => '11111', 'friend_count' => '12')); $follower_builders = array(); $follower_builders[] = FixtureBuilder::build('follows', array('user_id' => '930061', 'follower_id' => '2001', 'active' => 1, 'network' => 'twitter')); $follower_builders[] = FixtureBuilder::build('follows', array('user_id' => '930061', 'follower_id' => '123456', 'active' => 1, 'network' => 'twitter')); $controller = new PublicTimelineController(true); $results = $controller->control(); $this->assertTrue(strpos($results, "ginatrapani") > 0); //test if view variables were set correctly $v_mgr = $controller->getViewManager(); $this->assertIsA($v_mgr->getTemplateDataItem('user_details'), 'User'); $this->assertIsA($v_mgr->getTemplateDataItem('most_replied_to_alltime'), 'array'); $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('most_replied_to_alltime')), 5); $this->assertIsA($v_mgr->getTemplateDataItem('most_replied_to_1wk'), 'array'); $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('most_replied_to_1wk')), 5); $this->assertIsA($v_mgr->getTemplateDataItem('most_retweeted_alltime'), 'array'); $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('most_retweeted_1wk')), 2); $this->assertIsA($v_mgr->getTemplateDataItem('least_likely_followers'), 'array'); $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('least_likely_followers')), 2); $this->assertEqual($controller->getCacheKeyString(), 'public.tpl-ginatrapani-twitter', 'Cache key'); $this->assertIsA($v_mgr->getTemplateDataItem('all_time_clients_usage'), 'array'); $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('all_time_clients_usage')), 11); $this->assertIsA($v_mgr->getTemplateDataItem('latest_clients_usage'), 'array'); $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('latest_clients_usage')), 2); }