当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils::varDumpToString方法代码示例

本文整理汇总了PHP中Utils::varDumpToString方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::varDumpToString方法的具体用法?PHP Utils::varDumpToString怎么用?PHP Utils::varDumpToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils的用法示例。


在下文中一共展示了Utils::varDumpToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLongLostContactsInsight

 public function testLongLostContactsInsight()
 {
     // Get data ready that insight requires
     $builders = self::buildData();
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_user_id = 7612345;
     $instance->network_username = 'twitteruser';
     $instance->network = 'twitter';
     $insight_plugin = new LongLostContactsInsight();
     $insight_plugin->generateInsight($instance, $last_week_of_posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('long_lost_contacts', 10, $today);
     $contacts = unserialize($result->related_data);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertPattern('/\\@twitteruser hasn\'t replied to /', $result->text);
     $this->assertPattern('/<strong>2 contacts<\\/strong> /', $result->text);
     $this->assertPattern('/in over a year: /', $result->text);
     $this->assertNoPattern('/a contact/', $result->text);
     $this->assertIsA($contacts, "array");
     $this->assertIsA($contacts[0], "User");
     $this->assertEqual(count($contacts), 2);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:27,代码来源:TestOfLongLostContactsInsight.php

示例2: testSingleBigReshareBy2xFollowers

 public function testSingleBigReshareBy2xFollowers()
 {
     // Assert that insight doesn't exist
     $insight_dao = new InsightMySQLDAO();
     $yesterday = date('Y-m-d', strtotime('-1 day'));
     $result = $insight_dao->getInsight('big_reshare_1345', 10, $yesterday);
     $this->assertNull($result);
     //original post
     $post1_builder = FixtureBuilder::build('posts', array('id' => 1345, 'post_id' => '134', 'author_user_id' => 22, 'author_username' => 'quoter', 'author_fullname' => 'Quoter of Quotables', 'network' => 'twitter', 'post_text' => 'Be liberal in what you accept and conservative in what you send', 'source' => 'web', 'pub_date' => '-1d', 'reply_count_cache' => 0, 'retweet_count_cache' => 0, 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'is_protected' => 0, 'location' => 'New Delhi, Delhi, India', 'geo' => '28.635308,77.22496', 'is_geo_encoded' => 1));
     $post1_object = new Post($post1_builder->columns);
     $builders = self::buildData();
     //retweet author has 2x more followers
     $builders[] = FixtureBuilder::build('users', array('user_id' => '20', 'user_name' => 'user1', 'full_name' => 'User 1', 'description' => 'I am a user', 'avatar' => 'avatar.jpg', 'is_protected' => 0, 'follower_count' => 160, 'network' => 'twitter'));
     // Get data ready that insight requires
     $posts = array();
     $posts[] = $post1_object;
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_user_id = '22';
     $instance->network = 'twitter';
     $instance->network_username = 'testeriffic';
     $bigreshare_insight_plugin = new BigReshareInsight();
     $bigreshare_insight_plugin->generateInsight($instance, $this->getUser(), $posts, 3);
     // Assert that insight got generated
     $insight_dao = new InsightMySQLDAO();
     $yesterday = date('Y-m-d', strtotime('-1 day'));
     $result = $insight_dao->getInsight('big_reshare_1345', 10, $yesterday);
     $this->assertNotNull($result);
     $this->debug(Utils::varDumpToString($result));
     $this->assertEqual($result->slug, 'big_reshare_1345');
     $this->assertEqual($result->filename, 'bigreshare');
     $this->assertPattern('/Someone with \\<strong\\>2x\\<\\/strong\\> more followers retweeted \\@testeriffic/', $result->headline);
     $this->assertEqual('80 more people saw @testeriffic\'s tweet.', $result->text);
     $this->debug($this->getRenderedInsightInHTML($result));
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:35,代码来源:TestOfBigReshareInsight.php

示例3: testGetPhotoExists

 public function testGetPhotoExists()
 {
     $dao = new PhotoMySQLDAO();
     $result = $dao->getPhoto("507648000295407216_180890738", 'instagram');
     $this->debug(Utils::varDumpToString($result));
     $this->assertTrue(isset($result));
     $this->assertEqual($result->post_id, '507648000295407216_180890738');
     $this->assertEqual($result->author_user_id, '180890738');
     $this->assertEqual($result->author_username, 'nilakshdas');
     $this->assertEqual($result->author_fullname, 'Nilaksh Das');
     $avatar = 'http://images.ak.instagram.com/profiles/profile_180890738_75sq_1374737148.jpg';
     $this->assertEqual($result->author_avatar, $avatar);
     $this->assertEqual($result->post_text, '#LoseYourself, as usual.');
     $this->assertEqual($result->is_protected, false);
     $this->assertEqual($result->source, 'undefined');
     $this->assertEqual($result->pub_date, '2013-07-25 12:42:59');
     $this->assertEqual($result->network, 'instagram');
     $this->assertEqual($result->post_key, 5);
     $this->assertEqual($result->filter, 'Lo-fi');
     $srurl = 'http://distilleryimage0.s3.amazonaws.com/a2e8b5f0f4f911e2af6f22000a1f9a09_7.jpg';
     $this->assertEqual($result->standard_resolution_url, $srurl);
     $lrurl = 'http://distilleryimage0.s3.amazonaws.com/a2e8b5f0f4f911e2af6f22000a1f9a09_6.jpg';
     $this->assertEqual($result->low_resolution_url, $lrurl);
     $tnurl = 'http://distilleryimage0.s3.amazonaws.com/a2e8b5f0f4f911e2af6f22000a1f9a09_5.jpg';
     $this->assertEqual($result->thumbnail_url, $tnurl);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:26,代码来源:TestOfPhotoMySQLDAO.php

示例4: generateInsight

 public function generateInsight(Instance $instance, $last_week_of_posts, $number_days)
 {
     parent::generateInsight($instance, $last_week_of_posts, $number_days);
     $this->logger->logInfo("Begin generating insight", __METHOD__ . ',' . __LINE__);
     $filename = basename(__FILE__, ".php");
     // Follower count history milestone
     $insight_date = new DateTime();
     $insight_day_of_week = (int) $insight_date->format('w');
     $insight_day_of_month = (int) $insight_date->format('j');
     if ($insight_day_of_month == 1) {
         //it's the first day of the month
         $count_dao = DAOFactory::getDAO('CountHistoryDAO');
         //by month
         $follower_count_history_by_month = $count_dao->getHistory($instance->network_user_id, $instance->network, 'MONTH', 15, $this->insight_date);
         $insight_text = "<strong>";
         if (isset($follower_count_history_by_month['milestone']) && $follower_count_history_by_month["milestone"]["will_take"] > 0 && $follower_count_history_by_month["milestone"]["next_milestone"] > 0) {
             $insight_text .= $follower_count_history_by_month['milestone']['will_take'] . ' month';
             if ($follower_count_history_by_month['milestone']['will_take'] > 1) {
                 $insight_text .= 's';
             }
             $insight_text .= "</strong> till {$this->username} reaches <strong>" . number_format($follower_count_history_by_month['milestone']['next_milestone']);
             $insight_text .= '</strong> followers at the current growth rate.';
             $this->insight_dao->insertInsightDeprecated('follower_count_history_by_month_milestone', $instance->id, $this->insight_date, "Upcoming milestone:", $insight_text, $filename, Insight::EMPHASIS_LOW, serialize($follower_count_history_by_month));
         }
     } else {
         if ($insight_day_of_week == 0) {
             //it's Sunday
             $count_dao = DAOFactory::getDAO('CountHistoryDAO');
             //by week
             $follower_count_history_by_week = $count_dao->getHistory($instance->network_user_id, $instance->network, 'WEEK', 15, $this->insight_date);
             $this->logger->logInfo($this->insight_date . " is Sunday; Count by week stats are " . Utils::varDumpToString($follower_count_history_by_week), __METHOD__ . ',' . __LINE__);
             $insight_text = "<strong>";
             if (isset($follower_count_history_by_week['milestone']) && $follower_count_history_by_week["milestone"]["will_take"] > 0 && $follower_count_history_by_week["milestone"]["next_milestone"] > 0) {
                 $insight_text .= $follower_count_history_by_week['milestone']['will_take'] . ' week';
                 if ($follower_count_history_by_week['milestone']['will_take'] > 1) {
                     $insight_text .= 's';
                 }
                 $insight_text .= "</strong> till {$this->username} reaches <strong>" . number_format($follower_count_history_by_week['milestone']['next_milestone']);
                 $insight_text .= '</strong> followers at the current growth rate.';
                 $this->logger->logInfo("Storing insight " . $insight_text, __METHOD__ . ',' . __LINE__);
                 $this->insight_dao->insertInsightDeprecated('follower_count_history_by_week_milestone', $instance->id, $this->insight_date, "Upcoming milestone:", $insight_text, $filename, Insight::EMPHASIS_LOW, serialize($follower_count_history_by_week));
             }
         }
     }
     $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
 }
开发者ID:dgw,项目名称:ThinkUp,代码行数:46,代码来源:followercounthistory.php

示例5: testSetPopularPostPosts

 public function testSetPopularPostPosts()
 {
     $year = date('Y');
     $builders = self::setUpPublicInsight($this->instance);
     // set up posts
     // 2nd most popular post January
     $builders[] = FixtureBuilder::build('posts', array('id' => 11, 'post_id' => 11, 'author_username' => $this->instance->network_username, 'author_user_id' => $this->instance->network_user_id, 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => $this->instance->network, 'post_text' => 'This is a post that is less popular', 'source' => 'web', 'pub_date' => "{$year}-01-01", 'reply_count_cache' => 5, 'is_protected' => false));
     // 3rd most popular post January
     $builders[] = FixtureBuilder::build('posts', array('id' => 12, 'post_id' => 12, 'author_username' => $this->instance->network_username, 'author_user_id' => $this->instance->network_user_id, 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => $this->instance->network, 'post_text' => 'This is the least popular post', 'source' => 'web', 'pub_date' => "{$year}-01-01", 'reply_count_cache' => 1, 'is_protected' => false));
     // most popular post January
     $builders[] = FixtureBuilder::build('posts', array('id' => 10, 'post_id' => 10, 'author_username' => $this->instance->network_username, 'author_user_id' => $this->instance->network_user_id, 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => $this->instance->network, 'post_text' => 'This is the most popular post', 'source' => 'web', 'pub_date' => "{$year}-01-01", 'reply_count_cache' => 10, 'retweet_count_cache' => 20, 'favlike_count_cache' => 30));
     // 2nd most popular post Sept
     $builders[] = FixtureBuilder::build('posts', array('id' => 13, 'post_id' => 13, 'author_username' => $this->instance->network_username, 'author_user_id' => $this->instance->network_user_id, 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => $this->instance->network, 'post_text' => 'This is a post that is less popular', 'source' => 'web', 'pub_date' => "{$year}-09-15", 'reply_count_cache' => 5, 'is_protected' => false));
     // 3rd most popular post Sept
     $builders[] = FixtureBuilder::build('posts', array('id' => 14, 'post_id' => 14, 'author_username' => $this->instance->network_username, 'author_user_id' => $this->instance->network_user_id, 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => $this->instance->network, 'post_text' => 'This is the least popular post', 'source' => 'web', 'pub_date' => "{$year}-09-20", 'reply_count_cache' => 1, 'is_protected' => false));
     // most popular post Sept
     $builders[] = FixtureBuilder::build('posts', array('id' => 15, 'post_id' => 15, 'author_username' => $this->instance->network_username, 'author_user_id' => $this->instance->network_user_id, 'author_fullname' => 'Twitter User', 'author_avatar' => 'avatar.jpg', 'network' => $this->instance->network, 'post_text' => 'This is the most popular post', 'source' => 'web', 'pub_date' => "{$year}-09-30", 'reply_count_cache' => 10, 'retweet_count_cache' => 20, 'favlike_count_cache' => 30));
     $post_dao = DAOFactory::getDAO('PostDAO');
     $last_year_of_posts = $post_dao->getThisYearOfPostsIterator($author_id = $this->instance->network_user_id, $network = $this->instance->network);
     $insight_plugin = new EOYMostPopularPerMonthInsight();
     $scored_posts = $insight_plugin->setScoredPosts($last_year_of_posts);
     $this->debug(Utils::varDumpToString($insight_plugin->posts_per_month));
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:23,代码来源:TestOfEOYMostPopularPerMonthInsight.php

示例6: parseResults


//.........这里部分代码省略.........
             //$post['location'] = $item->location->postalCode;
             // Place ID is an ID foursquare provides
             $post['place_id'] = $item->venue->id;
             // Set geo to the lat,lng that foursquare provides
             $post['geo'] = $item->venue->location->lat . "," . $item->venue->location->lng;
             // These parameters cant be null but we don't need them for our plugin so set them to any empty string
             $post['reply_count_cache'] = '';
             $post['favlike_count_cache'] = '';
             $post['retweet_count_cache'] = '';
             $post['author_follower_count'] = '';
             // Store the checkin details in the database
             $done = $post_dao->addPost($post);
             if ($done != null) {
                 $number_stored++;
             }
             // Check if any photos are attached to this checkin
             if ($item->photos->count > 0 && $done != null) {
                 foreach ($item->photos->items as $photo) {
                     $photo_store = new Link(array('url' => $photo->url, 'expanded_url' => $photo->url, 'title' => ' ', 'description' => ' ', 'image_src' => $photo->url, 'caption' => ' ', 'clicks' => 0, 'post_key' => $done, 'error' => 'none'));
                     // Insert the photo into the database
                     $link_dao->insert($photo_store);
                     // Delete the current photo info ready for the next one
                     $photo_store = null;
                 }
             }
             // If there are any comments on this checkin capture them
             if ($item->comments->count > 0) {
                 // Make a query out for the comments
                 $comments = $this->api_accessor->apiRequest('checkins/' . $item->id, $this->access_token);
                 foreach ($comments->response->checkin->comments->items as $comment) {
                     // The post ID, is the comment ID foursquare provides
                     $comment_store['post_id'] = $comment->id;
                     // The post text is the comment they made
                     $comment_store['post_text'] = $comment->text;
                     // The author username is the users foursquare email address (which we need to query for)
                     $name = $this->api_accessor->apiRequest('users/' . $comment->user->id, $this->access_token);
                     $user_name = $name->response->user->contact->email;
                     $comment_store['author_username'] = isset($user_name) ? $user_name : 'email address withheld';
                     // The author full name is the name they gave foursquare
                     $comment_store['author_fullname'] = $comment->user->firstName . " " . $comment->user->lastName;
                     // The avatar is the one they have set on foursquare
                     $comment_store["author_avatar"] = $comment->user->photo->prefix . "100x100" . $comment->user->photo->suffix;
                     // The author user id is there foursquare user ID
                     $comment_store['author_user_id'] = $comment->user->id;
                     // The date they posted the comment
                     $comment_store['pub_date'] = date('Y-m-d H:i:s', $comment->createdAt);
                     // Source of the comment
                     $comment_store['source'] = "";
                     // Comments can not be private
                     $comment_store['is_protected'] = false;
                     // Set the network to foursquare
                     $comment_store['network'] = 'foursquare';
                     // Set place to the name of the place the comment is about
                     $comment_store['place'] = $comments->response->checkin->venue->name;
                     // A few parameters may or may not be set for location so let the method do the work
                     $comment_store['location'] = $this->getLocation($item);
                     // Place ID is an ID foursquare provides
                     $comment_store['place_id'] = $comments->response->checkin->venue->id;
                     // Set geo to the lat,lng that foursquare provides
                     $comment_store['geo'] = $item->venue->location->lat . "," . $item->venue->location->lng;
                     // The ID of the author of the checkin
                     $comment_store['in_reply_to_user_id'] = $user->response->user->id;
                     // The ID of the checkin this is a reply to
                     $comment_store['in_reply_to_post_id'] = $item->id;
                     // The number of replies this checkin has
                     $comment_store['reply_count_cache'] = $item->comments->count;
                     // These parameters cant be null but we don't need them so set them to any empty string
                     $comment_store['reply_count_cache'] = '';
                     $comment_store['favlike_count_cache'] = '';
                     $comment_store['retweet_count_cache'] = '';
                     $comment_store['author_follower_count'] = '';
                     self::fetchUser($comment_store['author_user_id'], 'comment');
                     // Now store the comment in the database
                     $post_dao->addPost($comment_store);
                     $comment = null;
                 }
             }
             // Store the details about this place in the place table if it doesn't already exist
             // See if this place is already in the database
             $place_test = $place_dao->getPlaceByID($item->venue->id);
             // If it isn't already in the database
             if ($place_test == null) {
                 // Insert it
                 $places['id'] = $item->venue->id;
                 $places['place_type'] = $item->venue->categories[0]->name;
                 $places['name'] = $item->venue->name;
                 $places['full_name'] = $item->venue->name;
                 $places['icon'] = $item->venue->categories[0]->icon->prefix . '64' . $item->venue->categories[0]->icon->suffix;
                 $places['lat_lng'] = 'POINT(' . $item->venue->location->lat . " " . $item->venue->location->lng . ')';
                 $places['map_image'] = $this->generateMap($item);
                 $place_dao->insertGenericPlace($places, 'foursquare');
             }
             // Blank out the details ready for the next checkin
             $post = null;
             $places = null;
         }
     } else {
         $this->logger->logInfo("No checkins found " . Utils::varDumpToString($checkins));
     }
 }
开发者ID:kuthulas,项目名称:ProjectX,代码行数:101,代码来源:class.FoursquareCrawler.php

示例7: testTrendMillionPlusGroupMemberships2

 public function testTrendMillionPlusGroupMemberships2()
 {
     $format = 'n/j';
     $date = date($format);
     $group_member_count = array('member_user_id' => '930061', 'network' => 'twitter', 'date' => '-1d', 'count' => 1272643);
     $builder1 = FixtureBuilder::build('group_member_count', $group_member_count);
     $group_member_count = array('member_user_id' => '930061', 'network' => 'twitter', 'date' => '-2d', 'count' => 1271684);
     $builder2 = FixtureBuilder::build('group_member_count', $group_member_count);
     $group_member_count = array('member_user_id' => '930061', 'network' => 'twitter', 'date' => '-3d', 'count' => 1271500);
     $builder3 = FixtureBuilder::build('group_member_count', $group_member_count);
     $group_member_count = array('member_user_id' => '930061', 'network' => 'twitter', 'date' => '-4d', 'count' => 1261500);
     $builder4 = FixtureBuilder::build('group_member_count', $group_member_count);
     $dao = new GroupMembershipCountMySQLDAO();
     $result = $dao->getHistory('930061', 'twitter', 'DAY', 4);
     $this->assertEqual(sizeof($result), 4, '4 sets of data returned--history, trend, milestone, and vis_data');
     $this->debug(Utils::varDumpToString($result));
     //check milestone
     //latest group membership count is 1.7M, next milestone is 2M
     //with a 2786+/day trend, this should take 82 days
     //beyond our "don't feel bad about yourself" threshold of 10, so should be null
     $this->assertNull($result['milestone']);
 }
开发者ID:73sl4,项目名称:ThinkUp,代码行数:22,代码来源:TestOfGroupMembershipCountMySQLDAO.php

示例8: testSuccessfulRegistration

    public function testSuccessfulRegistration()
    {
        $config = Config::getInstance();
        $site_root_path = $config->getValue('site_root_path');
        // make sure registration is on...
        $bvalues = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'is_registration_open', 'option_value' => 'true');
        $bdata = FixtureBuilder::build('options', $bvalues);
        $_SERVER['HTTP_HOST'] = "mytestthinkup";
        $_POST['Submit'] = 'Register';
        $_POST['full_name'] = "Angelina Jolie";
        $_POST['email'] = 'angie@example.com';
        $_POST['user_code'] = '123456';
        $_POST['pass1'] = 'mypass';
        $_POST['pass2'] = 'mypass';
        $controller = new RegisterController(true);
        $results = $controller->go();
        $v_mgr = $controller->getViewManager();
        $this->assertEqual($v_mgr->getTemplateDataItem('controller_title'), 'Register');
        $this->debug($v_mgr->getTemplateDataItem('success_msg'));
        $this->debug($v_mgr->getTemplateDataItem('error_msg'));
        $this->debug(Utils::varDumpToString($v_mgr->getTemplateDataItem('error_msgs')));
        $this->assertEqual($v_mgr->getTemplateDataItem('success_msg'), 'Success! Check your email for an activation link.');
        $expected_reg_email_pattern = '/to: angie@example.com
subject: Activate Your ThinkUp Account
message: Click on the link below to activate your new ThinkUp account:

http:\\/\\/mytestthinkup' . str_replace('/', '\\/', $site_root_path) . 'session\\/activate.php\\?usr=angie%40example.com/';
        $actual_reg_email = Mailer::getLastMail();
        $this->debug($actual_reg_email);
        $this->assertPattern($expected_reg_email_pattern, $actual_reg_email);
    }
开发者ID:narpaldhillon,项目名称:ThinkUp,代码行数:31,代码来源:TestOfRegisterController.php

示例9: setUpGPlusInteractions

 /**
  * Add user auth link or process incoming auth requests.
  * @param array $options Plugin options array
  */
 protected function setUpGPlusInteractions(array $options)
 {
     //get options
     $client_id = $options['google_plus_client_id']->option_value;
     $client_secret = $options['google_plus_client_secret']->option_value;
     //prep redirect URI
     $config = Config::getInstance();
     $site_root_path = $config->getValue('site_root_path');
     $redirect_uri = urlencode(Utils::getApplicationURL() . 'account/?p=google%2B');
     //create OAuth link
     $oauth_link = "https://accounts.google.com/o/oauth2/auth?client_id=" . $client_id . "&redirect_uri=" . $redirect_uri . "&scope=https://www.googleapis.com/auth/plus.me&response_type=code&access_type=offline&approval_prompt=force";
     $this->addToView('oauth_link', $oauth_link);
     // Google provided a code to get an access token
     if (isset($_GET['code'])) {
         $code = $_GET['code'];
         $crawler_plugin_registrar = new GooglePlusCrawler(null, null);
         $tokens = $crawler_plugin_registrar->getOAuthTokens($client_id, $client_secret, $code, 'authorization_code', $redirect_uri);
         if (isset($tokens->error)) {
             $this->addErrorMessage("Oops! Something went wrong while obtaining OAuth tokens.<br>Google says \"" . $tokens->error . ".\" Please double-check your settings and try again.", 'authorization');
         } else {
             if (isset($tokens->access_token) && isset($tokens->access_token)) {
                 //Get user data
                 $gplus_api_accessor = new GooglePlusAPIAccessor();
                 $gplus_user = $gplus_api_accessor->apiRequest('people/me', $tokens->access_token, null);
                 if (isset($gplus_user->error)) {
                     if ($gplus_user->error->code == "403" && $gplus_user->error->message == 'Access Not Configured') {
                         $this->addErrorMessage("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.", 'authorization');
                     } else {
                         $this->addErrorMessage("Oops! Something went wrong querying the Google+ API.<br>" . "Google says \"" . $gplus_user->error->code . ": " . $gplus_user->error->message . ".\" Please double-check your settings and try again.", 'authorization');
                     }
                 } else {
                     if (isset($gplus_user->id) && isset($gplus_user->displayName)) {
                         $gplus_user_id = $gplus_user->id;
                         $gplus_username = $gplus_user->displayName;
                         //Process tokens
                         $this->saveAccessTokens($gplus_user_id, $gplus_username, $tokens->access_token, $tokens->refresh_token);
                     } else {
                         $this->addErrorMessage("Oops! Something went wrong querying the Google+ API.<br>" . "Google says \"" . Utils::varDumpToString($gplus_user) . ".\" Please double-check your settings and try again.", 'authorization');
                     }
                 }
             } else {
                 $this->addErrorMessage("Oops! Something went wrong while obtaining OAuth tokens.<br>Google says \"" . Utils::varDumpToString($tokens) . ".\" Please double-check your settings and try again.", 'authorization');
             }
         }
     }
     $instance_dao = DAOFactory::getDAO('InstanceDAO');
     $owner_instances = $instance_dao->getByOwnerAndNetwork($this->owner, 'google+');
     $this->addToView('owner_instances', $owner_instances);
 }
开发者ID:kuthulas,项目名称:ProjectX,代码行数:53,代码来源:class.GooglePlusPluginConfigurationController.php

示例10: testSingleLongLostContact

 public function testSingleLongLostContact()
 {
     // Get data ready that insight requires
     $builders = self::buildData($multiple = false);
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_user_id = 7612345;
     $instance->network_username = 'twitteruser';
     $instance->network = 'twitter';
     $insight_plugin = new LongLostContactsInsight();
     $insight_plugin->generateInsight($instance, null, $last_week_of_posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('long_lost_contacts', 10, $today);
     $contacts = unserialize($result->related_data);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertPattern('/\\@twitteruser hasn\'t replied to /', $result->headline);
     $this->assertPattern('/Twitter Follower One /', $result->headline);
     $this->assertPattern('/in over a year/', $result->headline);
     $this->assertPattern('/avatar.jpg/', $result->header_image);
     $this->assertNoPattern('/people/', $result->headline);
     $this->assertIsA($contacts, "array");
     $this->assertIsA($contacts["people"][0], "User");
     $this->assertEqual(count($contacts["people"]), 1);
     $this->debug($this->getRenderedInsightInHTML($result));
     $this->debug($this->getRenderedInsightInEmail($result));
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:30,代码来源:TestOfLongLostContactsInsight.php

示例11: testGetExchangesBetweenUsers

 /**
  * Test getExchangesBetweenUsers
  */
 public function testGetExchangesBetweenUsers()
 {
     $dao = new PostMySQLDAO();
     $posts_replied_to = $dao->getExchangesBetweenUsers(18, 21, 'twitter');
     $this->assertEqual(sizeof($posts_replied_to), 2);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "shutterbug");
     $this->assertEqual($posts_replied_to[0]["question"], "This is image post 1");
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "user2");
     $this->assertEqual($posts_replied_to[0]["answer"], "@shutterbug Nice shot!");
     $this->assertEqual($posts_replied_to[1]["questioner_username"], "user2");
     $this->assertEqual($posts_replied_to[1]["question"], "@shutterbug Nice shot!");
     $this->assertEqual($posts_replied_to[1]["answerer_username"], "shutterbug");
     $this->assertEqual($posts_replied_to[1]["answer"], "@user2 Thanks!");
     $this->debug(Utils::varDumpToString($posts_replied_to));
     $posts_replied_to = $dao->getExchangesBetweenUsers(13, 20, 'twitter');
     $this->assertEqual(sizeof($posts_replied_to), 1);
     $this->assertEqual($posts_replied_to[0]["question_post_id"], 139);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "user1");
     $this->assertEqual($posts_replied_to[0]["question"], "@ev When will Twitter have a business model?");
     $this->assertEqual($posts_replied_to[0]['answer_post_id'], 140);
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "ev");
     $this->assertEqual($posts_replied_to[0]["answer"], "@user1 Soon...");
 }
开发者ID:narpaldhillon,项目名称:ThinkUp,代码行数:26,代码来源:TestOfPostMySQLDAO.php

示例12: testCrawlCompletion

 public function testCrawlCompletion()
 {
     $this->debug(__METHOD__);
     $builders = array();
     //Add instances
     $instance_builder_1 = FixtureBuilder::build('instances', array('id' => 1, 'network_username' => 'julie', 'network' => 'twitter', 'crawler_last_run' => '-5d', 'is_activated' => '1', 'is_public' => '1'));
     $instance_builder_2 = FixtureBuilder::build('instances', array('id' => 2, 'network_username' => 'john', 'network' => 'twitter', 'crawler_last_run' => '-5d', 'is_activated' => '1', 'is_public' => '1'));
     $builders[] = FixtureBuilder::build('instances_twitter', array('id' => 1));
     $builders[] = FixtureBuilder::build('instances_twitter', array('id' => 2));
     //Add owner
     $builders[] = FixtureBuilder::build('owners', array('id' => 1, 'full_name' => 'ThinkUp J. User', 'email' => 'me@example.com', 'is_activated' => 1, 'is_admin' => 1));
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 1, 'auth_error' => ''));
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 2, 'auth_error' => ''));
     $this->simulateLogin('me@example.com', true, true);
     $test = new TwitterInstanceMySQLDAO();
     $twitter_plugin = new TwitterPlugin();
     $twitter_plugin->crawl();
     $instance_dao = new InstanceMySQLDAO();
     $updated_instance = $instance_dao->get(1);
     $this->debug(Utils::varDumpToString($updated_instance));
     // crawler_last_run should have been updated
     $this->assertNotEqual($instance_builder_1->columns['crawler_last_run'], $updated_instance->crawler_last_run);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:23,代码来源:TestOfTwitterPlugin.php

示例13: testLinkUtilities

 public function testLinkUtilities()
 {
     $year = date('Y');
     $user_id = $this->instance->network_user_id;
     $counter = 12;
     $days = 0;
     // set up most links
     while ($counter != 0) {
         $post_key = $counter + 1760;
         $days++;
         $builders[] = FixtureBuilder::build('posts', array('id' => $post_key, 'post_id' => $post_key, 'network' => 'twitter', 'author_user_id' => $user_id, 'author_username' => 'user', 'in_reply_to_user_id' => NULL, 'in_retweet_of_post_id' => NULL, 'retweet_count_cache' => $days, 'reply_count_cache' => $days, 'favlike_count_cache' => $days, 'in_reply_to_post_id' => 0, 'is_protected' => 0, 'author_fullname' => 'User', 'post_text' => 'Link post http://lifehacker.com/' . $counter, 'pub_date' => '-1d'));
         $builders[] = FixtureBuilder::build('links', array('url' => 'http://lifehacker.com/' . $counter, 'title' => 'Link ' . $counter, 'post_key' => $post_key, 'expanded_url' => 'http://lifehacker.com/' . $counter, 'error' => '', 'image_src' => ''));
         $counter--;
     }
     // set up fewer links
     $counter = 10;
     $days = 0;
     while ($counter != 0) {
         $post_key = $counter + 1860;
         $days++;
         $builders[] = FixtureBuilder::build('posts', array('id' => $post_key, 'post_id' => $post_key, 'network' => 'twitter', 'author_user_id' => $user_id, 'author_username' => 'user', 'in_reply_to_user_id' => NULL, 'in_retweet_of_post_id' => NULL, 'in_reply_to_post_id' => 0, 'is_protected' => 0, 'author_fullname' => 'User', 'post_text' => 'Link post http://nytimes.com/' . $counter, 'pub_date' => '-1d'));
         $builders[] = FixtureBuilder::build('links', array('url' => 'http://nytimes.com/' . $counter, 'title' => 'Link ' . $counter, 'post_key' => $post_key, 'expanded_url' => 'http://nytimes.com/' . $counter, 'error' => '', 'image_src' => ''));
         $counter--;
     }
     $insight_plugin = new EOYMostLinksInsight();
     $post_dao = new PostMySQLDAO();
     $it_posts = $post_dao->getThisYearOfPostsWithLinksIterator($author_id = $this->instance->network_user_id, $network = $this->instance->network);
     $posts = array();
     foreach ($it_posts as $post) {
         $posts[] = $post;
     }
     $this->assertEqual(count($posts), 22);
     $domain_counts = $insight_plugin->getDomainCounts($posts);
     $this->debug(Utils::varDumpToString($domain_counts));
     $sorted_domains = array(0 => array('lifehacker.com' => 12), 1 => array('nytimes.com' => 10));
     $i = 0;
     foreach ($domain_counts as $domain => $count) {
         $this->assertEqual($sorted_domains[$i][$domain], $count);
         $i++;
     }
     $domain = $insight_plugin->getPopularDomain($domain_counts);
     $this->assertEqual('lifehacker.com', $domain);
     $posts = $insight_plugin->getMostPopularPostsLinkingTo($this->instance, $domain);
     $this->debug(Utils::varDumpToString($posts));
     $this->assertEqual(3, count($posts));
     $this->assertEqual($posts[0]->id, 1761);
     $this->assertEqual($posts[2]->id, 1763);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:48,代码来源:TestOfEOYMostLinksInsight.php

示例14: testOlympic2014InsightRegeneration

 public function testOlympic2014InsightRegeneration()
 {
     // Get data ready that insight requires
     $instance = new Instance();
     $instance->id = 3;
     $instance->network_username = 'catlady99';
     $instance->network = 'twitter';
     $builders = self::setUpPublicInsight($instance);
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'These were amazing opening ceremonies in sochi!', 'pub_date' => '2014-02-07', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'The olympic closing ceremony is the greatest global event since Beyonce\'s album', 'pub_date' => '2014-02-07', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'Hope nothing else goes wrong! #sochi2014', 'pub_date' => '2014-02-19', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $posts = array();
     $insight_plugin = new Olympics2014Insight();
     $insight_plugin->generateInsight($instance, null, $posts, 3);
     // Assert that insight got inserted
     $insight_dao = new InsightMySQLDAO();
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('olympics_2014', 3, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertIsA($result, "Insight");
     $this->assertEqual('Do they give out medals for tweets?', $result->headline);
     $this->assertEqual('@catlady99 mentioned the Olympics 5 times since they started. That\'s kind of like ' . 'winning 5 gold medals in Twitter, right?', $result->text);
     //Add a new post that should update the insight with 2 more mentions
     $builders[] = FixtureBuilder::build('posts', array('post_text' => 'Great closing ceremony! #sochi2014', 'pub_date' => '2014-02-21', 'author_username' => $instance->network_username, 'network' => $instance->network));
     $insight_plugin->generateInsight($instance, null, $posts, 3);
     // Assert that insight got updated
     $today = date('Y-m-d');
     $result = $insight_dao->getInsight('olympics_2014', 3, $today);
     $this->debug(Utils::varDumpToString($result));
     $this->assertNotNull($result);
     $this->assertEqual('@catlady99 mentioned the Olympics 7 times since they started. That\'s kind of like ' . 'winning 7 gold medals in Twitter, right?', $result->text);
     $controller = new InsightStreamController();
     $_GET['u'] = 'catlady99';
     $_GET['n'] = 'twitter';
     $_GET['d'] = date('Y-m-d');
     $_GET['s'] = 'olympics_2014';
     $results = $controller->go();
     //output this to an HTML file to see the insight fully rendered
     //$this->debug($results);
     //Test email rendering
     $email_insight = $this->getRenderedInsightInEmail($result);
     //$this->debug($email_insight);
 }
开发者ID:pepeleproso,项目名称:ThinkUp,代码行数:44,代码来源:TestOfOlympics2014Insight.php

示例15: generateInsight


//.........这里部分代码省略.........
         $response_avg_timediffs = array();
         for ($hotd = 0; $hotd < 24; $hotd++) {
             for ($dotm = 1; $dotm <= 30; $dotm++) {
                 $punchcard['posts'][$dotm][$hotd] = 0;
                 $punchcard['responses'][$dotm][$hotd] = 0;
             }
             $responses_chron[$hotd] = 0;
         }
         // $this->logger->logInfo("Last month's posts: ".Utils::varDumpToString($last_months_posts),
         //     __METHOD__.','.__LINE__);
         if ($instance->network !== 'instagram') {
             //count replies and retweets
             foreach ($last_months_posts as $post) {
                 $responses = array();
                 $responses = array_merge((array) $post_dao->getRepliesToPost($post->post_id, $post->network), (array) $post_dao->getRetweetsOfPost($post->post_id, $post->network));
                 foreach ($responses as $response) {
                     $response_pub_date = new DateTime($response->pub_date);
                     $response_dotm = date('j', date('U', strtotime($response->pub_date) + $offset));
                     // Day of month
                     $response_hotd = date('G', date('U', strtotime($response->pub_date) + $offset));
                     // Hour of day
                     $punchcard['responses'][$response_dotm][$response_hotd]++;
                     $responses_chron[$response_hotd]++;
                 }
                 $post_pub_date = new DateTime($post->pub_date);
                 $post_dotm = date('j', date('U', strtotime($post->pub_date) + $offset));
                 // Day of the month
                 $post_hotd = date('G', date('U', strtotime($post->pub_date) + $offset));
                 // Hour of the day
                 $punchcard['posts'][$post_dotm][$post_hotd]++;
             }
         } else {
             //count likes
             foreach ($last_months_posts as $post) {
                 $post_pub_date = new DateTime($post->pub_date);
                 $post_dotm = date('j', date('U', strtotime($post->pub_date) + $offset));
                 // Day of month
                 $post_hotd = date('G', date('U', strtotime($post->pub_date) + $offset));
                 // Hour of day
                 $punchcard['responses'][$post_dotm][$post_hotd]++;
                 //$this->logger->logInfo("HOTD: ".$post_hotd, __METHOD__.','.__LINE__);
                 $responses_chron[$post_hotd] += $post->favlike_count_cache;
                 $punchcard['posts'][$post_dotm][$post_hotd]++;
             }
         }
         arsort($responses_chron);
         $most_responses = each($responses_chron);
         $insight_text = '';
         if ($most_responses['value'] > 2) {
             $time1_low_hotd = $most_responses['key'];
             $time1_high_hotd = $time1_low_hotd + 1;
             $time1_low = ($time1_low_hotd % 12 ? $time1_low_hotd % 12 : 12) . (floor($time1_low_hotd / 12) == 1 ? 'pm' : 'am');
             $time1_high = ($time1_high_hotd % 12 ? $time1_high_hotd % 12 : 12) . (floor($time1_high_hotd / 12) == 1 ? 'pm' : 'am');
             $plural = $most_responses['value'] == 1 ? InsightTerms::SINGULAR : InsightTerms::PLURAL;
             if ($instance->network == 'instagram') {
                 $insight_text = "In the past month, what " . $this->username . " posted " . "between <strong>" . $time1_low . " and " . $time1_high . "</strong> on Instagram got the most love - " . $most_responses['value'] . " " . $this->terms->getNoun('like', $plural) . " in all.";
             } else {
                 $insight_text = "In the past month, " . $this->username . "'s " . $this->terms->getNoun('post', InsightTerms::PLURAL) . " got the biggest response between <strong>" . $time1_low . " and " . $time1_high . "</strong> - " . $most_responses['value'] . " " . $this->terms->getNoun('reply', $plural) . " in all.";
             }
             // $this->logger->logInfo("Responses chron: ".Utils::varDumpToString($responses_chron),
             //     __METHOD__.','.__LINE__);
             foreach ($responses_chron as $key => $value) {
                 if ($value > 0 && $value < $most_responses['value']) {
                     $time2_low_hotd = $key;
                     $time2_high_hotd = $time2_low_hotd + 1;
                     $time2_low = ($time2_low_hotd % 12 ? $time2_low_hotd % 12 : 12) . (floor($time2_low_hotd / 12) == 1 ? 'pm' : 'am');
                     $time2_high = ($time2_high_hotd % 12 ? $time2_high_hotd % 12 : 12) . (floor($time2_high_hotd / 12) == 1 ? 'pm' : 'am');
                     if ($instance->network == 'instagram') {
                         $response_text = $value > 1 ? 'hearts' : 'heart';
                     } else {
                         $response_text = $value > 1 ? 'responses' : 'response';
                     }
                     $comparison_text = " That's compared to " . $value . " " . $response_text . " between " . $time2_low . " and " . $time2_high . ". ";
                 }
             }
             $insight_text .= $comparison_text;
             $headline = $this->username . "'s best time is around " . $time1_low;
             $optimal_hour = substr($time1_low, 0, -2);
             //Instantiate the Insight object
             $my_insight = new Insight();
             //REQUIRED: Set the insight's required attributes
             $my_insight->instance_id = $instance->id;
             $my_insight->slug = $this->slug;
             //slug to label this insight's content
             $my_insight->date = $this->insight_date;
             //date of the data this insight applies to
             $my_insight->headline = $headline;
             $my_insight->text = $insight_text;
             $my_insight->header_image = '';
             $my_insight->emphasis = Insight::EMPHASIS_HIGH;
             $my_insight->filename = basename(__FILE__, ".php");
             // $my_insight->related_data = $punchcard;
             $my_insight->related_data = $optimal_hour;
             $this->insight_dao->insertInsight($my_insight);
         } else {
             $this->logger->logInfo("No insight: Most responses is " . Utils::varDumpToString($most_responses), __METHOD__ . ',' . __LINE__);
         }
     }
     $this->logger->logInfo("Done generating insight", __METHOD__ . ',' . __LINE__);
 }
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:101,代码来源:outreachpunchcard.php


注:本文中的Utils::varDumpToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。