コード例 #1
0
 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");
 }
コード例 #2
0
 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);
 }