Changeset 13980
- Timestamp:
- 07/27/2024 04:30:23 PM (8 months ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 73 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/assets/group-extensions.php
r10905 r13980 94 94 return $this->setup_class_info(); 95 95 } 96 97 96 } 98 97 -
trunk/tests/phpunit/includes/factory.php
r13874 r13980 2 2 #[AllowDynamicProperties] 3 3 class BP_UnitTest_Factory extends WP_UnitTest_Factory { 4 public $activity = null; 5 6 function __construct() { 4 public function __construct() { 7 5 parent::__construct(); 8 6 9 $this->user = new BP_UnitTest_Factory_For_User( $this );10 $this->activity = new BP_UnitTest_Factory_For_Activity( $this );11 $this->group = new BP_UnitTest_Factory_For_Group( $this );12 $this->message = new BP_UnitTest_Factory_For_Message( $this );7 $this->user = new BP_UnitTest_Factory_For_User( $this ); 8 $this->activity = new BP_UnitTest_Factory_For_Activity( $this ); 9 $this->group = new BP_UnitTest_Factory_For_Group( $this ); 10 $this->message = new BP_UnitTest_Factory_For_Message( $this ); 13 11 $this->xprofile_group = new BP_UnitTest_Factory_For_XProfileGroup( $this ); 14 12 $this->xprofile_field = new BP_UnitTest_Factory_For_XProfileField( $this ); 15 $this->notification = new BP_UnitTest_Factory_For_Notification( $this );16 $this->signup = new BP_UnitTest_Factory_For_Signup( $this );17 $this->friendship = new BP_UnitTest_Factory_For_Friendship( $this );13 $this->notification = new BP_UnitTest_Factory_For_Notification( $this ); 14 $this->signup = new BP_UnitTest_Factory_For_Signup( $this ); 15 $this->friendship = new BP_UnitTest_Factory_For_Friendship( $this ); 18 16 } 19 17 } … … 52 50 class BP_UnitTest_Factory_For_Activity extends WP_UnitTest_Factory_For_Thing { 53 51 54 function __construct( $factory = null ) {52 public function __construct( $factory = null ) { 55 53 parent::__construct( $factory ); 56 54 … … 64 62 } 65 63 66 function create_object( $args ) {67 if ( ! isset( $args['user_id'] ) ) 64 public function create_object( $args ) { 65 if ( ! isset( $args['user_id'] ) ) { 68 66 $args['user_id'] = get_current_user_id(); 67 } 69 68 70 69 return bp_activity_add( $args ); 71 70 } 72 71 73 function update_object( $activity_id, $fields ) {72 public function update_object( $activity_id, $fields ) { 74 73 $activity = new BP_Activity_Activity( $activity_id ); 75 74 76 75 foreach ( $fields as $field_name => $value ) { 77 if ( isset( $activity->$field_name ) ) 76 if ( isset( $activity->$field_name ) ) { 78 77 $activity->$field_name = $value; 78 } 79 79 } 80 80 81 81 $activity->save(); 82 82 83 return $activity; 83 84 } 84 85 85 function get_object_by_id( $user_id ) {86 public function get_object_by_id( $user_id ) { 86 87 return new BP_Activity_Activity( $user_id ); 87 88 } … … 90 91 class BP_UnitTest_Factory_For_Group extends WP_UnitTest_Factory_For_Thing { 91 92 92 function __construct( $factory = null ) {93 public function __construct( $factory = null ) { 93 94 parent::__construct( $factory ); 94 95 … … 104 105 } 105 106 106 function create_object( $args ) {107 public function create_object( $args ) { 107 108 if ( ! isset( $args['creator_id'] ) ) { 108 109 if ( is_user_logged_in() ) { … … 112 113 } else { 113 114 $last_activity = date( 'Y-m-d H:i:s', strtotime( bp_core_current_time() ) - 60 * 60 * 24 * 365 ); 114 $user_factory = new WP_UnitTest_Factory_For_User();115 115 $args['creator_id'] = $this->factory->user->create( array( 'role' => 'subscriber' ) ); 116 116 … … 138 138 } 139 139 140 function update_object( $group_id, $fields ) {140 public function update_object( $group_id, $fields ) { 141 141 $group = new BP_Groups_Group( $group_id ); 142 142 143 143 foreach ( $fields as $field_name => $value ) { 144 if ( isset( $group->field_name ) ) 144 if ( isset( $group->field_name ) ) { 145 145 $group->field_name = $value; 146 } 146 147 } 147 148 148 149 $group->save(); 150 149 151 return $group; 150 152 } 151 153 152 function get_object_by_id( $group_id ) {154 public function get_object_by_id( $group_id ) { 153 155 return new BP_Groups_Group( $group_id ); 154 156 } … … 157 159 class BP_UnitTest_Factory_For_Message extends WP_UnitTest_Factory_For_Thing { 158 160 159 function __construct( $factory = null ) {161 public function __construct( $factory = null ) { 160 162 parent::__construct( $factory ); 161 163 … … 169 171 } 170 172 171 function create_object( $args ) {173 public function create_object( $args ) { 172 174 if ( empty( $args['sender_id'] ) ) { 173 175 $args['sender_id'] = $this->factory->user->create(); … … 185 187 } 186 188 187 function update_object( $message_id, $fields ) { 188 // todo 189 } 190 191 function get_object_by_id( $message_id ) { 189 public function update_object( $message_id, $fields ) {} 190 191 public function get_object_by_id( $message_id ) { 192 192 return new BP_Messages_Message( $message_id ); 193 193 } … … 196 196 class BP_UnitTest_Factory_For_XProfileGroup extends WP_UnitTest_Factory_For_Thing { 197 197 198 function __construct( $factory = null ) {198 public function __construct( $factory = null ) { 199 199 parent::__construct( $factory ); 200 200 … … 206 206 } 207 207 208 function create_object( $args ) { 209 $group_id = xprofile_insert_field_group( $args ); 210 return $group_id; 211 } 212 213 function update_object( $group_id, $fields ) { 214 } 215 216 function get_object_by_id( $group_id ) { 208 public function create_object( $args ) { 209 return xprofile_insert_field_group( $args ); 210 } 211 212 public function update_object( $group_id, $fields ) {} 213 214 public function get_object_by_id( $group_id ) { 217 215 return new BP_XProfile_Group( $group_id ); 218 216 } … … 221 219 class BP_UnitTest_Factory_For_XProfileField extends WP_UnitTest_Factory_For_Thing { 222 220 223 function __construct( $factory = null ) {221 public function __construct( $factory = null ) { 224 222 parent::__construct( $factory ); 225 223 … … 231 229 } 232 230 233 function create_object( $args ) { 234 $field_id = xprofile_insert_field( $args ); 235 return $field_id; 236 } 237 238 function update_object( $field_id, $fields ) { 239 } 240 241 function get_object_by_id( $field_id ) { 231 public function create_object( $args ) { 232 return xprofile_insert_field( $args ); 233 } 234 235 public function update_object( $field_id, $fields ) {} 236 237 public function get_object_by_id( $field_id ) { 242 238 return new BP_XProfile_Field( $field_id ); 243 239 } … … 245 241 246 242 class BP_UnitTest_Factory_For_Notification extends WP_UnitTest_Factory_For_Thing { 247 public function __construct( $factory = null ) {248 parent::__construct( $factory );249 }250 251 243 public function create_object( $args ) { 252 244 return bp_notifications_add_notification( $args ); … … 261 253 262 254 class BP_UnitTest_Factory_For_Signup extends WP_UnitTest_Factory_For_Thing { 263 public function __construct( $factory = null ) {264 parent::__construct( $factory );265 }266 267 255 public function create_object( $args ) { 268 256 return BP_Signup::add( $args ); … … 282 270 */ 283 271 class BP_UnitTest_Factory_For_Friendship extends WP_UnitTest_Factory_For_Thing { 284 /** 285 * Constructor. 286 * 287 * @since 2.7.0 288 * 289 * @param $factory WP_UnitTest_Factory 290 */ 291 public function __construct( $factory = null ) { 292 parent::__construct( $factory ); 293 } 294 295 /** 296 * Create friendship object. 297 * 298 * @since 2.7.0 299 * 300 * @param array $args Array of arguments. 301 * @return int Friendship ID. 302 */ 272 303 273 public function create_object( $args ) { 304 274 $friendship = new BP_Friends_Friendship(); … … 323 293 } 324 294 325 /**326 * Update a friendship object.327 *328 * @since 2.7.0329 *330 * @todo Implement.331 *332 * @param int $id ID of the friendship.333 * @param array $fields Fields to update.334 */335 295 public function update_object( $id, $fields ) {} 336 296 337 /**338 * Get a friendship object by its ID.339 *340 * @since 2.7.0341 *342 * @param int $id343 * @return BP_Friends_Friendship344 */345 297 public function get_object_by_id( $id ) { 346 298 return new BP_Friends_Friendship( $id ); -
trunk/tests/phpunit/includes/mock-mailer.php
r10470 r13980 11 11 * Send email(s). 12 12 * 13 * @since 2.5.0 14 * 13 15 * @param BP_Email $email Email to send. 14 * @return bool False if some error occurred. 15 * @since 2.5.0 16 * @return bool 16 17 */ 17 18 public function bp_email( BP_Email $email ) { -
trunk/tests/phpunit/includes/testcase-emails.php
r13314 r13980 15 15 bp_core_install_emails(); 16 16 } 17 18 public static function tear_down_after_class() {19 $emails = get_posts( array(20 'fields' => 'ids',21 'post_status' => 'any',22 'post_type' => bp_get_email_post_type(),23 'posts_per_page' => 200,24 'suppress_filters' => false,25 ) );26 27 if ( $emails ) {28 foreach ( $emails as $email_id ) {29 wp_delete_post( $email_id, true );30 }31 }32 33 parent::tear_down_after_class();34 }35 17 } -
trunk/tests/phpunit/includes/testcase.php
r13468 r13980 1 1 <?php 2 2 3 require_once dirname( __FILE__ ). '/factory.php';3 require_once __DIR__ . '/factory.php'; 4 4 5 5 class BP_UnitTestCase extends WP_UnitTestCase { 6 6 7 /** 8 * Temp storage for users who have the bp_moderate capability. 9 * 10 * @var array 11 */ 7 12 protected $temp_has_bp_moderate = array(); 13 14 /** 15 * A cached copy of the SERVER_NAME global. 16 * 17 * @var string 18 */ 8 19 protected static $cached_SERVER_NAME = null; 9 20 … … 32 43 */ 33 44 public static function set_up_before_class() { 34 global $wpdb;35 36 45 // Fake WP mail globals, to avoid errors 37 46 add_filter( 'wp_mail', array( 'BP_UnitTestCase', 'setUp_wp_mail' ) ); 38 47 add_filter( 'wp_mail_from', array( 'BP_UnitTestCase', 'tearDown_wp_mail' ) ); 39 48 40 $c = self::get_called_class(); 49 $c = get_called_class(); 50 41 51 if ( ! method_exists( $c, 'wpSetUpBeforeClass' ) ) { 42 52 self::commit_transaction(); … … 58 68 bp_core_add_page_mappings( bp_get_option( 'bp-active-components' ), 'delete' ); 59 69 60 61 $this->factory = new BP_UnitTest_Factory; 70 $this->factory = self::factory(); 62 71 63 72 // Fixes warnings in multisite functions 64 73 $_SERVER['REMOTE_ADDR'] = ''; 65 global $wpdb;66 74 67 75 // Clean up after autocommits. … … 112 120 * 113 121 * @since 3.0.0 122 * 123 * @param int $user_id User ID. 124 * @return bool True on success, false on failure. 114 125 */ 115 126 public static function delete_user( $user_id ) { … … 127 138 128 139 public function clean_up_global_scope() { 129 buddypress()->bp_nav = buddypress()->bp_options_nav = buddypress()->action_variables = buddypress()->canonical_stack = buddypress()->unfiltered_uri = $GLOBALS['bp_unfiltered_uri'] = array(); 130 buddypress()->current_component = buddypress()->current_item = buddypress()->current_action = buddypress()->current_member_type = ''; 131 buddypress()->unfiltered_uri_offset = 0; 132 buddypress()->is_single_item = false; 133 buddypress()->current_user = new stdClass(); 134 buddypress()->displayed_user = new stdClass(); 135 buddypress()->loggedin_user = new stdClass(); 136 buddypress()->pages = array(); 137 buddypress()->groups->types = array(); 140 $bp = buddypress(); 141 142 $GLOBALS['bp_unfiltered_uri'] = array(); 143 144 $bp->bp_nav = array(); 145 $bp->bp_options_nav = array(); 146 $bp->action_variables = array(); 147 $bp->canonical_stack = array(); 148 $bp->unfiltered_uri = array(); 149 $bp->current_component = ''; 150 $bp->current_item = ''; 151 $bp->current_action = ''; 152 $bp->current_member_type = ''; 153 $bp->unfiltered_uri_offset = 0; 154 $bp->is_single_item = false; 155 $bp->current_user = new stdClass(); 156 $bp->displayed_user = new stdClass(); 157 $bp->loggedin_user = new stdClass(); 158 $bp->pages = array(); 159 $bp->groups->types = array(); 138 160 139 161 parent::clean_up_global_scope(); … … 191 213 192 214 public function go_to( $url ) { 193 $GLOBALS['bp']->loggedin_user = NULL;194 $GLOBALS['bp']->pages = bp_core_get_directory_pages();215 $GLOBALS['bp']->loggedin_user = null; 216 $GLOBALS['bp']->pages = bp_core_get_directory_pages(); 195 217 196 218 foreach ( array_keys( bp_core_get_active_components() ) as $component ) { 197 219 $GLOBALS['bp']->{$component}->main_nav = array(); 198 $GLOBALS['bp']->{$component}->sub_nav = array();220 $GLOBALS['bp']->{$component}->sub_nav = array(); 199 221 } 200 222 … … 221 243 $bp = buddypress(); 222 244 223 $bp->loggedin_user->id = $user_id;245 $bp->loggedin_user->id = $user_id; 224 246 $bp->loggedin_user->fullname = bp_core_get_user_displayname( $user_id ); 225 $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin =is_super_admin( $user_id );247 $bp->loggedin_user->is_super_admin = is_super_admin( $user_id ); 226 248 $bp->loggedin_user->domain = bp_members_get_user_url( $user_id ); 227 249 $bp->loggedin_user->userdata = bp_core_get_core_userdata( $user_id ); … … 231 253 232 254 public static function add_user_to_group( $user_id, $group_id, $args = array() ) { 233 $r = bp_parse_args( $args, array( 234 'date_modified' => bp_core_current_time(), 235 'is_confirmed' => 1, 236 'is_admin' => 0, 237 'is_mod' => 0, 238 'invite_sent' => 0, 239 'inviter_id' => 0, 240 ) ); 241 242 $new_member = new BP_Groups_Member; 255 $r = bp_parse_args( 256 $args, 257 array( 258 'date_modified' => bp_core_current_time(), 259 'is_confirmed' => 1, 260 'is_admin' => 0, 261 'is_mod' => 0, 262 'invite_sent' => 0, 263 'inviter_id' => 0, 264 ) 265 ); 266 267 $new_member = new BP_Groups_Member(); 243 268 $new_member->group_id = $group_id; 244 269 $new_member->user_id = $user_id; 245 $new_member->inviter_id = 0;246 270 $new_member->is_admin = $r['is_admin']; 247 271 $new_member->is_mod = $r['is_mod']; … … 253 277 254 278 $new_member->save(); 279 255 280 return $new_member->id; 256 281 } … … 267 292 } 268 293 269 $user = get_userdata( $user_id );294 $user = get_userdata( $user_id ); 270 295 $super_admins[] = $user->user_login; 271 296 } … … 332 357 public static function tearDown_wp_mail( $args ) { 333 358 if ( ! empty( self::$cached_SERVER_NAME ) ) { 334 $_SERVER['SERVER_NAME'] = self::$cached_SERVER_NAME;359 $_SERVER['SERVER_NAME'] = self::$cached_SERVER_NAME; 335 360 self::$cached_SERVER_NAME = ''; 336 361 } else { … … 348 373 global $wpdb; 349 374 $wpdb->query( 'COMMIT;' ); 375 } 376 377 /** 378 * Set a flag that an autocommit has taken place inside of a test method. 379 * 380 * @since 2.4.0 381 */ 382 public function set_autocommit_flag() { 383 $this->autocommitted = true; 384 } 385 386 /** 387 * Deactivate a component for the duration of a test. 388 * 389 * @since 2.4.0 390 * 391 * @param string $component Component name. 392 */ 393 public function deactivate_component( $component ) { 394 if ( ! isset( $component ) ) { 395 return; 396 } 397 398 unset( buddypress()->active_components[ $component ] ); 399 400 $this->deactivated_components[] = $component; 350 401 } 351 402 … … 375 426 376 427 /** 377 * Set a flag that an autocommit has taken place inside of a test method.378 *379 * @since 2.4.0380 */381 public function set_autocommit_flag() {382 $this->autocommitted = true;383 }384 385 /**386 * Deactivate a component for the duration of a test.387 *388 * @since 2.4.0389 *390 * @param string $component Component name.391 */392 public function deactivate_component( $component ) {393 $is_active = isset( buddypress()->active_components[ $component ] );394 395 if ( ! isset( $component ) ) {396 return false;397 }398 399 unset( buddypress()->active_components[ $component ] );400 $this->deactivated_components[] = $component;401 }402 403 /**404 428 * Fake an attachment upload (doesn't actually upload a file). 405 429 * 406 430 * @param string $file Absolute path to valid file. 407 * @param int $parent Optional. Post ID to attach the new post to.431 * @param int $parent Optional. Post ID to attach the new post to. 408 432 * @return int Attachment post ID. 409 433 */ … … 416 440 } 417 441 418 $url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . basename( $file );442 $url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . basename( $file ); 419 443 $attachment = array( 420 444 'guid' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $url, -
trunk/tests/phpunit/testcases/activity/filters.php
r13433 r13980 57 57 $this->assertEquals( $at_name_in_mailto_final, bp_activity_at_name_filter( $at_name_in_mailto ) ); 58 58 } 59 60 59 } -
trunk/tests/phpunit/testcases/activity/functions.php
r13636 r13980 1416 1416 // bp_activity_add_user_favorite() requires a logged-in user. 1417 1417 $current_user = bp_loggedin_user_id(); 1418 $this->set_current_user( $u );1418 self::set_current_user( $u ); 1419 1419 1420 1420 $this->assertTrue( bp_activity_add_user_favorite( $a, $u ) ); … … 1424 1424 $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) ); 1425 1425 1426 $this->set_current_user( $current_user );1426 self::set_current_user( $current_user ); 1427 1427 } 1428 1428 … … 1437 1437 // bp_activity_add_user_favorite() requires a logged-in user. 1438 1438 $current_user = bp_loggedin_user_id(); 1439 $this->set_current_user( $u );1439 self::set_current_user( $u ); 1440 1440 $this->assertTrue( bp_activity_add_user_favorite( $a, $u ) ); 1441 1441 1442 $this->set_current_user( $current_user );1442 self::set_current_user( $current_user ); 1443 1443 } 1444 1444 … … 1454 1454 // bp_activity_add_user_favorite() requires a logged-in user. 1455 1455 $current_user = bp_loggedin_user_id(); 1456 $this->set_current_user( $u1 );1456 self::set_current_user( $u1 ); 1457 1457 1458 1458 // Only favorite for user 1 … … 1463 1463 $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) ); 1464 1464 1465 $this->set_current_user( $current_user );1465 self::set_current_user( $current_user ); 1466 1466 } 1467 1467 … … 1476 1476 // bp_activity_add_user_favorite() requires a logged-in user. 1477 1477 $current_user = bp_loggedin_user_id(); 1478 $this->set_current_user( $u1 );1478 self::set_current_user( $u1 ); 1479 1479 1480 1480 // Only favorite for user 1 … … 1490 1490 $this->assertEquals( 1, bp_activity_get_meta( $a, 'favorite_count' ) ); 1491 1491 1492 $this->set_current_user( $current_user );1492 self::set_current_user( $current_user ); 1493 1493 } 1494 1494 … … 1621 1621 $this->assertTrue( bp_activity_user_can_read( $o, $u ) ); 1622 1622 1623 $this->set_current_user( $u2 );1623 self::set_current_user( $u2 ); 1624 1624 $this->assertTrue( bp_activity_user_can_read( $o, $u2 ) ); 1625 1625 } … … 1659 1659 bp_activity_mark_as_spam( $o ); 1660 1660 1661 $this->set_current_user( $u2 );1661 self::set_current_user( $u2 ); 1662 1662 $this->assertTrue( bp_activity_user_can_read( $o, $u2 ) ); 1663 1663 } -
trunk/tests/phpunit/testcases/activity/functions/bpActivityGetActions.php
r13314 r13980 21 21 22 22 public function tear_down() { 23 parent::tear_down();24 23 $bp = buddypress(); 25 24 … … 31 30 unset( $bp->activity->actions_sorted ); 32 31 } 32 parent::tear_down(); 33 33 } 34 34 -
trunk/tests/phpunit/testcases/activity/notifications.php
r13468 r13980 20 20 $this->u1 = self::factory()->user->create(); 21 21 $this->u2 = self::factory()->user->create(); 22 $this->set_current_user( $this->u1 );22 self::set_current_user( $this->u1 ); 23 23 24 24 /** … … 32 32 33 33 public function tear_down() { 34 $this->set_current_user( $this->current_user );34 self::set_current_user( $this->current_user ); 35 35 $this->set_permalink_structure( $this->permalink_structure ); 36 37 parent::tear_down();38 36 39 37 // Restore the filter 40 38 add_filter( 'bp_activity_at_name_do_notifications', '__return_false' ); 39 40 parent::tear_down(); 41 41 } 42 42 … … 90 90 91 91 // Log out 92 $this->set_current_user( 0 );92 self::set_current_user( 0 ); 93 93 94 94 // Go to the activity permalink page … … 110 110 $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) ); 111 111 112 $this->set_current_user( $this->u1 );112 self::set_current_user( $this->u1 ); 113 113 } 114 114 … … 129 129 130 130 // Switch user 131 $this->set_current_user( $this->u2 );131 self::set_current_user( $this->u2 ); 132 132 133 133 // Go to the activity permalink page … … 149 149 $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) ); 150 150 151 $this->set_current_user( $this->u1 );151 self::set_current_user( $this->u1 ); 152 152 } 153 153 … … 202 202 203 203 // Log out 204 $this->set_current_user( 0 );204 self::set_current_user( 0 ); 205 205 206 206 // Go to the My Activity page … … 223 223 224 224 // clean up 225 $this->set_current_user( $this->u1 );225 self::set_current_user( $this->u1 ); 226 226 } 227 227 … … 242 242 243 243 // Log out 244 $this->set_current_user( $this->u2 );244 self::set_current_user( $this->u2 ); 245 245 246 246 // Go to the My Activity page … … 263 263 264 264 // clean up 265 $this->set_current_user( $this->u1 );265 self::set_current_user( $this->u1 ); 266 266 } 267 267 … … 444 444 445 445 // Attempt to mark 'comment_reply' notifications as read for user 2. 446 $this->set_current_user( $this->u2 );446 self::set_current_user( $this->u2 ); 447 447 foreach ( $u2_notifications as $i => $n ) { 448 448 $n = bp_activity_format_notifications( $n->component_action, $n->item_id, $n->secondary_item_id, 1, 'array', $n->id ); … … 471 471 $u3 = self::factory()->user->create(); 472 472 473 $this->set_current_user( $u1 );473 self::set_current_user( $u1 ); 474 474 $userdata = get_userdata( $u1 ); 475 475 … … 487 487 ) ); 488 488 489 $this->set_current_user( $u2 );489 self::set_current_user( $u2 ); 490 490 $userdata = get_userdata( $u2 ); 491 491 … … 503 503 self::factory()->comment->update_object( $c1, array( 'comment_approved' => 1 ) ); 504 504 505 $this->set_current_user( $u3 );505 self::set_current_user( $u3 ); 506 506 $userdata = get_userdata( $u3 ); 507 507 … … 543 543 544 544 // Reset. 545 $this->set_current_user( $old_user );545 self::set_current_user( $old_user ); 546 546 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 547 547 remove_filter( 'comment_flood_filter', '__return_false' ); 548 548 } 549 550 549 } -
trunk/tests/phpunit/testcases/activity/template.php
r11737 r13980 12 12 $u = self::factory()->user->create(); 13 13 $original_user = bp_loggedin_user_id(); 14 $this->set_current_user( $u );14 self::set_current_user( $u ); 15 15 16 16 $a = self::factory()->activity->create( array( … … 24 24 25 25 // Logged-out user can't delete 26 $this->set_current_user( 0 );26 self::set_current_user( 0 ); 27 27 $this->assertFalse( bp_activity_user_can_delete( $activity ) ); 28 28 29 29 // Miscellaneous user can't delete 30 30 $misc_user = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 31 $this->set_current_user( $misc_user );31 self::set_current_user( $misc_user ); 32 32 $this->assertFalse( bp_activity_user_can_delete( $activity ) ); 33 33 … … 43 43 $bp->is_single_item = $is_single_item; 44 44 $bp->is_item_admin = $is_item_admin; 45 $this->set_current_user( $original_user );45 self::set_current_user( $original_user ); 46 46 } 47 47 … … 53 53 $old_user = get_current_user_id(); 54 54 $u = self::factory()->user->create(); 55 $this->set_current_user( $u );55 self::set_current_user( $u ); 56 56 57 57 // create an activity update for the user … … 70 70 71 71 // reset 72 $this->set_current_user( $old_user );72 self::set_current_user( $old_user ); 73 73 } 74 74 … … 96 96 97 97 $current_user = bp_loggedin_user_id(); 98 $this->set_current_user( $user_id );98 self::set_current_user( $user_id ); 99 99 100 100 bp_activity_add_user_favorite( $a1, $user_id ); 101 101 bp_activity_add_user_favorite( $a2, $user_id ); 102 102 103 $this->set_current_user( $current_user );103 self::set_current_user( $current_user ); 104 104 105 105 // groan. It sucks that you have to invoke the global … … 146 146 // save the current user and override logged-in user 147 147 $old_user = get_current_user_id(); 148 $this->set_current_user( $u1 );148 self::set_current_user( $u1 ); 149 149 150 150 $now = time(); … … 188 188 // clean up! 189 189 $activities_template = null; 190 $this->set_current_user( $old_user );190 self::set_current_user( $old_user ); 191 191 } 192 192 … … 1007 1007 $u3 = self::factory()->user->create(); 1008 1008 1009 $this->set_current_user( $u1 );1009 self::set_current_user( $u1 ); 1010 1010 1011 1011 $g = self::factory()->group->create( array( … … 1061 1061 $u3 = self::factory()->user->create(); 1062 1062 1063 $this->set_current_user( $u1 );1063 self::set_current_user( $u1 ); 1064 1064 1065 1065 $g = self::factory()->group->create( array( -
trunk/tests/phpunit/testcases/admin/functions.php
r13777 r13980 9 9 parent::set_up(); 10 10 $this->old_current_user = get_current_user_id(); 11 $this->set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );11 self::set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 12 12 13 13 if ( ! function_exists( 'bp_admin' ) ) { … … 21 21 22 22 public function tear_down() { 23 self::set_current_user( $this->old_current_user ); 23 24 parent::tear_down(); 24 $this->set_current_user( $this->old_current_user );25 25 } 26 26 -
trunk/tests/phpunit/testcases/blogs/activity.php
r13642 r13980 300 300 $old_user = get_current_user_id(); 301 301 $u = self::factory()->user->create(); 302 $this->set_current_user( $u );302 self::set_current_user( $u ); 303 303 $userdata = get_userdata( $u ); 304 304 … … 338 338 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 339 339 340 $this->set_current_user( $old_user );340 self::set_current_user( $old_user ); 341 341 } 342 342 … … 348 348 $old_user = get_current_user_id(); 349 349 $u = self::factory()->user->create(); 350 $this->set_current_user( $u );350 self::set_current_user( $u ); 351 351 $userdata = get_userdata( $u ); 352 352 … … 386 386 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 387 387 388 $this->set_current_user( $old_user );388 self::set_current_user( $old_user ); 389 389 } 390 390 … … 396 396 $old_user = get_current_user_id(); 397 397 $u = self::factory()->user->create(); 398 $this->set_current_user( $u );398 self::set_current_user( $u ); 399 399 $userdata = get_userdata( $u ); 400 400 … … 446 446 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 447 447 448 $this->set_current_user( $old_user );448 self::set_current_user( $old_user ); 449 449 } 450 450 … … 456 456 $old_user = get_current_user_id(); 457 457 $u = self::factory()->user->create(); 458 $this->set_current_user( $u );458 self::set_current_user( $u ); 459 459 $userdata = get_userdata( $u ); 460 460 … … 503 503 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 504 504 505 $this->set_current_user( $old_user );505 self::set_current_user( $old_user ); 506 506 } 507 507 … … 513 513 $old_user = get_current_user_id(); 514 514 $u = self::factory()->user->create(); 515 $this->set_current_user( $u );515 self::set_current_user( $u ); 516 516 $userdata = get_userdata( $u ); 517 517 … … 560 560 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 561 561 562 $this->set_current_user( $old_user );562 self::set_current_user( $old_user ); 563 563 } 564 564 … … 570 570 $old_user = get_current_user_id(); 571 571 $u = self::factory()->user->create(); 572 $this->set_current_user( $u );572 self::set_current_user( $u ); 573 573 $userdata = get_userdata( $u ); 574 574 … … 614 614 remove_action( 'bp_activity_before_save', array( $this, 'set_activity_to_spam' ) ); 615 615 616 $this->set_current_user( $old_user );616 self::set_current_user( $old_user ); 617 617 } 618 618 … … 626 626 $reset_at = isset( $GLOBALS['activities_template'] ) ? $GLOBALS['activities_template'] : null; 627 627 628 $this->set_current_user( $u );628 self::set_current_user( $u ); 629 629 630 630 // let's use activity comments instead of single "new_blog_comment" activity items … … 673 673 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 674 674 $GLOBALS['activities_template'] = $reset_at; 675 $this->set_current_user( $old_user );675 self::set_current_user( $old_user ); 676 676 } 677 677 … … 685 685 $reset_at = isset( $GLOBALS['activities_template'] ) ? $GLOBALS['activities_template'] : null; 686 686 687 $this->set_current_user( $u );687 self::set_current_user( $u ); 688 688 689 689 // let's use activity comments instead of single "new_blog_comment" activity items … … 731 731 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 732 732 $GLOBALS['activities_template'] = $reset_at; 733 $this->set_current_user( $old_user );733 self::set_current_user( $old_user ); 734 734 } 735 735 -
trunk/tests/phpunit/testcases/blogs/cache.php
r12606 r13980 99 99 // Switch user so we have access to non-public blogs 100 100 $old_user = get_current_user_id(); 101 $this->set_current_user( $u );101 self::set_current_user( $u ); 102 102 103 103 $b1 = self::factory()->blog->create(); … … 177 177 } 178 178 179 $this->set_current_user( $old_user );179 self::set_current_user( $old_user ); 180 180 } 181 181 … … 193 193 // Switch user so we have access to non-public blogs 194 194 $old_user = get_current_user_id(); 195 $this->set_current_user( $u );195 self::set_current_user( $u ); 196 196 197 197 $b1 = self::factory()->blog->create(); … … 230 230 $this->assertFalse( wp_cache_get( $b2, 'bp_blog_meta' ) ); 231 231 232 $this->set_current_user( $old_user );232 self::set_current_user( $old_user ); 233 233 } 234 234 -
trunk/tests/phpunit/testcases/blogs/class-bp-blogs-blog.php
r13184 r13980 14 14 15 15 $u = self::factory()->user->create(); 16 $this->set_current_user( $u );16 self::set_current_user( $u ); 17 17 $b = self::factory()->blog->create( array( 18 18 'title' => 'The Foo Bar Blog', … … 44 44 45 45 $u = self::factory()->user->create(); 46 $this->set_current_user( $u );46 self::set_current_user( $u ); 47 47 $b = self::factory()->blog->create( array( 48 48 'title' => 'The Foo Bar Blog', … … 74 74 75 75 $u = self::factory()->user->create(); 76 $this->set_current_user( $u );76 self::set_current_user( $u ); 77 77 $b = self::factory()->blog->create( array( 78 78 'title' => 'The Foo Bar Blog', … … 103 103 104 104 $u = self::factory()->user->create(); 105 $this->set_current_user( $u );105 self::set_current_user( $u ); 106 106 $b = self::factory()->blog->create( array( 107 107 'title' => 'Foo Bar Blog', … … 131 131 132 132 $u = self::factory()->user->create(); 133 $this->set_current_user( $u );133 self::set_current_user( $u ); 134 134 $bs = array( 135 135 'foobar' => self::factory()->blog->create( array( … … 176 176 $this->assertTrue( 2 == count( $blogs['blogs'] ) ); 177 177 178 $this->set_current_user( $old_user );178 self::set_current_user( $old_user ); 179 179 } 180 180 … … 189 189 $old_user = get_current_user_id(); 190 190 $u = self::factory()->user->create(); 191 $this->set_current_user( $u );191 self::set_current_user( $u ); 192 192 193 193 $r = [ … … 230 230 $old_user = get_current_user_id(); 231 231 $u = self::factory()->user->create(); 232 $this->set_current_user( $u );232 self::set_current_user( $u ); 233 233 234 234 $r = [ … … 273 273 $old_user = get_current_user_id(); 274 274 $u = self::factory()->user->create(); 275 $this->set_current_user( $u );275 self::set_current_user( $u ); 276 276 277 277 $r = [ -
trunk/tests/phpunit/testcases/blogs/filters.php
r13314 r13980 24 24 25 25 function tear_down() { 26 parent::tear_down();27 28 $bp = buddypress();29 30 26 _unregister_post_type( 'using_old_filter' ); 31 27 remove_filter( 'bp_blogs_record_post_post_types', array( $this, 'filter_post_types' ), 10 ); 32 28 remove_filter( 'bp_blogs_record_comment_post_types', array( $this, 'filter_post_types' ), 10 ); 29 30 parent::tear_down(); 33 31 } 34 32 -
trunk/tests/phpunit/testcases/blogs/functions.php
r13414 r13980 521 521 $old_user = get_current_user_id(); 522 522 $u = self::factory()->user->create(); 523 $this->set_current_user( $u );523 self::set_current_user( $u ); 524 524 $userdata = get_userdata( $u ); 525 525 … … 594 594 595 595 // reset 596 $this->set_current_user( $old_user );596 self::set_current_user( $old_user ); 597 597 } 598 598 … … 606 606 $old_user = get_current_user_id(); 607 607 $u = self::factory()->user->create(); 608 $this->set_current_user( $u );608 self::set_current_user( $u ); 609 609 $userdata = get_userdata( $u ); 610 610 … … 657 657 658 658 // reset 659 $this->set_current_user( $old_user );659 self::set_current_user( $old_user ); 660 660 remove_filter( 'bp_disable_blogforum_comments', '__return_false' ); 661 661 } … … 668 668 $old_user = get_current_user_id(); 669 669 $u = self::factory()->user->create(); 670 $this->set_current_user( $u );670 self::set_current_user( $u ); 671 671 $userdata = get_userdata( $u ); 672 672 … … 766 766 $old_user = get_current_user_id(); 767 767 $u = self::factory()->user->create(); 768 $this->set_current_user( $u );768 self::set_current_user( $u ); 769 769 $userdata = get_userdata( $u ); 770 770 $this->activity_saved_comment_count = 0; … … 819 819 $this->activity_saved_comment_count = 0; 820 820 $this->comment_saved_count = 0; 821 $this->set_current_user( $old_user );821 self::set_current_user( $old_user ); 822 822 } 823 823 … … 830 830 $old_user = get_current_user_id(); 831 831 $u = self::factory()->user->create(); 832 $this->set_current_user( $u );832 self::set_current_user( $u ); 833 833 834 834 // Get user details … … 879 879 $this->assertNotNull( $a1, 'Activity item was not created for existing blog post when recording post comment.' ); 880 880 881 $this->set_current_user( $old_user );881 self::set_current_user( $old_user ); 882 882 } 883 883 … … 1005 1005 1006 1006 $u = self::factory()->user->create(); 1007 $this->set_current_user( $u );1007 self::set_current_user( $u ); 1008 1008 1009 1009 // Create three sites. … … 1023 1023 $this->assertSame( 3, (int) $blogs['total'] ); 1024 1024 1025 $this->set_current_user( $old_user );1025 self::set_current_user( $old_user ); 1026 1026 } 1027 1027 … … 1041 1041 1042 1042 $u = self::factory()->user->create(); 1043 $this->set_current_user( $u );1043 self::set_current_user( $u ); 1044 1044 1045 1045 // Create three sites. … … 1070 1070 1071 1071 $_POST = $reset_post; 1072 $this->set_current_user( $old_user );1072 self::set_current_user( $old_user ); 1073 1073 } 1074 1074 … … 1088 1088 1089 1089 $u = self::factory()->user->create(); 1090 $this->set_current_user( $u );1090 self::set_current_user( $u ); 1091 1091 1092 1092 // Create three sites. … … 1117 1117 1118 1118 $_POST = $reset_post; 1119 $this->set_current_user( $old_user );1119 self::set_current_user( $old_user ); 1120 1120 } 1121 1121 -
trunk/tests/phpunit/testcases/core/avatars.php
r13417 r13980 9 9 protected $allowed_image_mimes = array( 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/png', 'image/webp' ); 10 10 11 public function set_up() {12 parent::set_up();13 }14 15 11 private function clean_existing_avatars( $type = 'user' ) { 16 12 if ( 'user' === $type ) { 17 13 $avatar_dir = 'avatars'; 18 } elseif ( 'group' === $ object) {14 } elseif ( 'group' === $type ) { 19 15 $avatar_dir = 'group-avatars'; 20 16 } -
trunk/tests/phpunit/testcases/core/caps.php
r13314 r13980 20 20 21 21 public function tear_down() { 22 self::set_current_user( $this->reset_user_id ); 22 23 parent::tear_down(); 23 24 $this->set_current_user( $this->reset_user_id );25 24 } 26 25 … … 33 32 $u = self::factory()->user->create(); 34 33 35 $this->set_current_user( $u );34 self::set_current_user( $u ); 36 35 37 36 add_filter( 'user_has_cap', array( $this, 'grant_cap_foo' ), 10, 2 ); … … 55 54 $u = self::factory()->user->create(); 56 55 57 $this->set_current_user( $u );56 self::set_current_user( $u ); 58 57 59 58 add_filter( 'user_has_cap', array( $this, 'grant_cap_foo' ), 10, 2 ); … … 89 88 ); 90 89 91 $this->set_current_user( $u );90 self::set_current_user( $u ); 92 91 93 92 $this->assertTrue( bp_current_user_can( 'bp_moderate' ), 'Administrator can `bp_moderate` on default WordPress config' ); … … 109 108 ); 110 109 111 $this->set_current_user( $u );110 self::set_current_user( $u ); 112 111 113 112 $this->assertTrue( bp_current_user_can( 'bp_moderate' ), 'Users having a `manage_options` cap into their role can `bp_moderate`' ); … … 131 130 ); 132 131 133 $this->set_current_user( $u1 );132 self::set_current_user( $u1 ); 134 133 135 134 $email = self::factory()->post->create( … … 141 140 $this->assertTrue( current_user_can( 'edit_post', $email ), 'Administrator should be able to edit emails they created' ); 142 141 143 $this->set_current_user( $u2 );142 self::set_current_user( $u2 ); 144 143 145 144 $this->assertTrue( current_user_can( 'edit_post', $email ), 'Administrator should be able to edit emails others created when BuddyPress is not network activated' ); … … 172 171 switch_to_blog( $this->blog_id ); 173 172 174 $this->set_current_user( $u1 );173 self::set_current_user( $u1 ); 175 174 $this->assertTrue( bp_current_user_can( 'bp_moderate' ), 'Only Super Admins can `bp_moderate` when BuddyPress is network activated' ); 176 175 177 $this->set_current_user( $u2 );176 self::set_current_user( $u2 ); 178 177 179 178 $this->assertFalse( bp_current_user_can( 'bp_moderate' ), 'Regular Admins cannot `bp_moderate` when BuddyPress is network activated' ); … … 220 219 restore_current_blog(); 221 220 222 $this->set_current_user( $u1 );221 self::set_current_user( $u1 ); 223 222 $this->assertTrue( current_user_can( 'edit_post', $email ), 'Super Admins should be able to edit emails they created' ); 224 223 225 $this->set_current_user( $u2 );224 self::set_current_user( $u2 ); 226 225 $this->assertFalse( current_user_can( 'edit_post', $email ), 'Administrator should not be able to edit emails others created when BuddyPress is network activated' ); 227 226 -
trunk/tests/phpunit/testcases/core/class-bp-attachment.php
r13414 r13980 23 23 24 24 public function tear_down() { 25 parent::tear_down();26 25 remove_filter( 'bp_attachment_upload_overrides', array( $this, 'filter_overrides' ), 10 ); 27 26 remove_filter( 'upload_dir', array( $this, 'filter_upload_dir' ), 20 ); … … 30 29 $this->image_file = ''; 31 30 $this->original_upload_dir = array(); 31 parent::tear_down(); 32 32 } 33 33 -
trunk/tests/phpunit/testcases/core/class-bp-button.php
r13433 r13980 24 24 public function test_block_self_own_profile() { 25 25 $u = self::factory()->user->create(); 26 $this->set_current_user( $u );26 self::set_current_user( $u ); 27 27 $this->set_permalink_structure( '/%postname%/' ); 28 28 … … 43 43 public function test_block_self_others_profile() { 44 44 $u1 = self::factory()->user->create(); 45 $this->set_current_user( $u1 );45 self::set_current_user( $u1 ); 46 46 $this->set_permalink_structure( '/%postname%/' ); 47 47 … … 70 70 ) ); 71 71 72 $this->set_current_user( $u1 );72 self::set_current_user( $u1 ); 73 73 74 74 $found = array(); … … 110 110 ) ); 111 111 112 $this->set_current_user( $u1 );112 self::set_current_user( $u1 ); 113 113 114 114 $found = array(); … … 150 150 ) ); 151 151 152 $this->set_current_user( $u1 );152 self::set_current_user( $u1 ); 153 153 $this->set_permalink_structure( '/%postname%/' ); 154 154 $this->go_to( bp_members_get_user_url( $u1 ) ); -
trunk/tests/phpunit/testcases/core/class-bp-email.php
r13905 r13980 300 300 301 301 public function test_sending_email() { 302 require_once( BP_PLUGIN_DIR . '/bp-core/admin/bp-core-admin-schema.php' );303 bp_core_install_emails();304 305 $user1 = get_user_by( 'id', $this->u1 );306 302 $result = bp_send_email( 'activity-comment', $this->u1, array( 307 303 'tokens' => array( … … 343 339 $this->assertSame( $name, $email->get_subject( 'replace-tokens' ) ); 344 340 } 345 346 341 } -
trunk/tests/phpunit/testcases/core/class-bp-user-query.php
r13878 r13980 101 101 102 102 $old_user = get_current_user_id(); 103 $this->set_current_user( $u1 );103 self::set_current_user( $u1 ); 104 104 105 105 // pass 'user_ids' to user query to trigger this bug … … 112 112 113 113 // clean up 114 $this->set_current_user( $old_user );114 self::set_current_user( $old_user ); 115 115 } 116 116 … … 862 862 $this->assertEquals( $u1, $query->user_ids[0] ); 863 863 } 864 865 864 } -
trunk/tests/phpunit/testcases/core/class-bp-walker-nav-menu.php
r13442 r13980 14 14 15 15 $this->user_id = self::factory()->user->create(); 16 $this->set_current_user( $this->user_id );16 self::set_current_user( $this->user_id ); 17 17 } 18 18 19 19 public function tear_down() { 20 self::set_current_user( $this->reset_user_id ); 20 21 parent::tear_down(); 21 $this->set_current_user( $this->reset_user_id );22 22 } 23 23 -
trunk/tests/phpunit/testcases/core/community-visibility.php
r13533 r13980 11 11 $this->old_user = get_current_user_id(); 12 12 $this->logged_in_user = self::factory()->user->create(); 13 $this->set_current_user( $this->logged_in_user );13 self::set_current_user( $this->logged_in_user ); 14 14 15 15 // Save a typical setting. … … 21 21 22 22 public function tear_down() { 23 parent::tear_down(); 24 $this->set_current_user( $this->old_user ); 23 self::set_current_user( $this->old_user ); 25 24 // Reset site to totally open. 26 25 delete_option( '_bp_community_visibility' ); 26 parent::tear_down(); 27 27 } 28 28 -
trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageId.php
r13436 r13980 15 15 16 16 public function tear_down() { 17 $this->set_permalink_structure( $this->permalink_structure ); 17 18 parent::tear_down(); 18 $this->set_permalink_structure( $this->permalink_structure );19 19 } 20 20 -
trunk/tests/phpunit/testcases/core/invitations.php
r13082 r13980 11 11 $old_current_user = get_current_user_id(); 12 12 13 $u1 = $this->factory->user->create();14 $u2 = $this->factory->user->create();15 $u3 = $this->factory->user->create();16 $this->set_current_user( $u1 );13 $u1 = self::factory()->user->create(); 14 $u2 = self::factory()->user->create(); 15 $u3 = self::factory()->user->create(); 16 self::set_current_user( $u1 ); 17 17 18 18 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 36 36 $this->assertEqualSets( array( $i1, $i2 ), $invites ); 37 37 38 $this->set_current_user( $old_current_user );38 self::set_current_user( $old_current_user ); 39 39 } 40 40 … … 42 42 $old_current_user = get_current_user_id(); 43 43 44 $u1 = $this->factory->user->create();45 $u2 = $this->factory->user->create();46 $this->set_current_user( $u1 );44 $u1 = self::factory()->user->create(); 45 $u2 = self::factory()->user->create(); 46 self::set_current_user( $u1 ); 47 47 48 48 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 60 60 $this->assertEquals( $i1, $i2 ); 61 61 62 $this->set_current_user( $old_current_user );62 self::set_current_user( $old_current_user ); 63 63 } 64 64 … … 66 66 $old_current_user = get_current_user_id(); 67 67 68 $u1 = $this->factory->user->create();69 $u2 = $this->factory->user->create();70 $u3 = $this->factory->user->create();71 $this->set_current_user( $u1 );68 $u1 = self::factory()->user->create(); 69 $u2 = self::factory()->user->create(); 70 $u3 = self::factory()->user->create(); 71 self::set_current_user( $u1 ); 72 72 73 73 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 96 96 $this->assertEqualSets( array( $i1 ), wp_list_pluck( $invites, 'id' ) ); 97 97 98 $this->set_current_user( $old_current_user );98 self::set_current_user( $old_current_user ); 99 99 } 100 100 … … 102 102 $old_current_user = get_current_user_id(); 103 103 104 $u1 = $this->factory->user->create();105 $u2 = $this->factory->user->create();106 $u3 = $this->factory->user->create();107 $this->set_current_user( $u1 );104 $u1 = self::factory()->user->create(); 105 $u2 = self::factory()->user->create(); 106 $u3 = self::factory()->user->create(); 107 self::set_current_user( $u1 ); 108 108 109 109 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 132 132 $this->assertEqualSets( array(), wp_list_pluck( $invites, 'id' ) ); 133 133 134 $this->set_current_user( $old_current_user );134 self::set_current_user( $old_current_user ); 135 135 } 136 136 … … 138 138 $old_current_user = get_current_user_id(); 139 139 140 $u1 = $this->factory->user->create();141 $u2 = $this->factory->user->create();142 $u3 = $this->factory->user->create();143 $this->set_current_user( $u1 );140 $u1 = self::factory()->user->create(); 141 $u2 = self::factory()->user->create(); 142 $u3 = self::factory()->user->create(); 143 self::set_current_user( $u1 ); 144 144 145 145 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 173 173 $this->assertEqualSets( array( $i1, $r1 ), $invites ); 174 174 175 $this->set_current_user( $old_current_user );175 self::set_current_user( $old_current_user ); 176 176 } 177 177 … … 179 179 $old_current_user = get_current_user_id(); 180 180 181 $u1 = $this->factory->user->create();182 $this->set_current_user( $u1 );181 $u1 = self::factory()->user->create(); 182 self::set_current_user( $u1 ); 183 183 184 184 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 200 200 $this->assertEqualSets( array( $r1, $r2 ), $requests ); 201 201 202 $this->set_current_user( $old_current_user );202 self::set_current_user( $old_current_user ); 203 203 } 204 204 … … 208 208 $invites_class = new BPTest_Invitation_Manager_Extension(); 209 209 210 $u1 = $this->factory->user->create();211 $this->set_current_user( $u1 );210 $u1 = self::factory()->user->create(); 211 self::set_current_user( $u1 ); 212 212 213 213 // Create a couple of requests. … … 220 220 $this->assertFalse( $invites_class->add_request( $request_args ) ); 221 221 222 $this->set_current_user( $old_current_user );222 self::set_current_user( $old_current_user ); 223 223 } 224 224 … … 226 226 $old_current_user = get_current_user_id(); 227 227 228 $u1 = $this->factory->user->create();229 $u2 = $this->factory->user->create();230 $this->set_current_user( $u1 );228 $u1 = self::factory()->user->create(); 229 $u2 = self::factory()->user->create(); 230 self::set_current_user( $u1 ); 231 231 232 232 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 258 258 $this->assertEqualSets( array( $r1, $i1 ), $invites ); 259 259 260 $this->set_current_user( $old_current_user );260 self::set_current_user( $old_current_user ); 261 261 } 262 262 … … 264 264 $old_current_user = get_current_user_id(); 265 265 266 $u1 = $this->factory->user->create();267 $u2 = $this->factory->user->create();268 $this->set_current_user( $u1 );266 $u1 = self::factory()->user->create(); 267 $u2 = self::factory()->user->create(); 268 self::set_current_user( $u1 ); 269 269 270 270 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 286 286 $this->assertEquals( 1, $invite->invite_sent ); 287 287 288 $this->set_current_user( $old_current_user );288 self::set_current_user( $old_current_user ); 289 289 } 290 290 … … 292 292 $old_current_user = get_current_user_id(); 293 293 294 $u1 = $this->factory->user->create();295 $u2 = $this->factory->user->create();296 $this->set_current_user( $u1 );294 $u1 = self::factory()->user->create(); 295 $u2 = self::factory()->user->create(); 296 self::set_current_user( $u1 ); 297 297 298 298 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 331 331 $this->assertEqualSets( array( $i2 ), $invites ); 332 332 333 $this->set_current_user( $old_current_user );333 self::set_current_user( $old_current_user ); 334 334 } 335 335 … … 337 337 $old_current_user = get_current_user_id(); 338 338 339 $u1 = $this->factory->user->create();340 $this->set_current_user( $u1 );339 $u1 = self::factory()->user->create(); 340 self::set_current_user( $u1 ); 341 341 342 342 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 353 353 $this->assertEquals( $time, $req->date_modified ); 354 354 355 $this->set_current_user( $old_current_user );355 self::set_current_user( $old_current_user ); 356 356 } 357 357 … … 359 359 $old_current_user = get_current_user_id(); 360 360 361 $u1 = $this->factory->user->create();362 $u2 = $this->factory->user->create();363 $this->set_current_user( $u1 );361 $u1 = self::factory()->user->create(); 362 $u2 = self::factory()->user->create(); 363 self::set_current_user( $u1 ); 364 364 365 365 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 379 379 $this->assertEquals( $time, $inv->date_modified ); 380 380 381 $this->set_current_user( $old_current_user );381 self::set_current_user( $old_current_user ); 382 382 } 383 383 … … 385 385 $old_current_user = get_current_user_id(); 386 386 387 $u1 = $this->factory->user->create();388 $u2 = $this->factory->user->create();389 $u3 = $this->factory->user->create();390 $this->set_current_user( $u1 );387 $u1 = self::factory()->user->create(); 388 $u2 = self::factory()->user->create(); 389 $u3 = self::factory()->user->create(); 390 self::set_current_user( $u1 ); 391 391 392 392 $invites_class = new BPTest_Invitation_Manager_Extension(); … … 429 429 $this->assertEquals( array( $i3, $i1, $i2 ), $invites ); 430 430 431 $this->set_current_user( $old_current_user );431 self::set_current_user( $old_current_user ); 432 432 } 433 433 } -
trunk/tests/phpunit/testcases/core/nav/bpCoreMaybeHookNewSubnavScreenFunction.php
r13437 r13980 49 49 public function test_user_has_access_false_user_logged_out() { 50 50 $old_current_user = get_current_user_id(); 51 $this->set_current_user( 0 );51 self::set_current_user( 0 ); 52 52 53 53 $subnav_item = array( … … 62 62 $this->assertSame( $expected, bp_core_maybe_hook_new_subnav_screen_function( $subnav_item ) ); 63 63 64 $this->set_current_user( $old_current_user );64 self::set_current_user( $old_current_user ); 65 65 } 66 66 … … 68 68 $u = self::factory()->user->create(); 69 69 $old_current_user = get_current_user_id(); 70 $this->set_current_user( $u );70 self::set_current_user( $u ); 71 71 $this->set_permalink_structure( '/%postname%/' ); 72 72 … … 82 82 $this->assertSame( bp_members_get_user_url( $u ), $found['redirect_args']['root'] ); 83 83 84 $this->set_current_user( $old_current_user );84 self::set_current_user( $old_current_user ); 85 85 } 86 86 … … 89 89 $u2 = self::factory()->user->create(); 90 90 $old_current_user = get_current_user_id(); 91 $this->set_current_user( $u1 );91 self::set_current_user( $u1 ); 92 92 $this->set_permalink_structure( '/%postname%/' ); 93 93 … … 113 113 114 114 // Clean up 115 $this->set_current_user( $old_current_user );115 self::set_current_user( $old_current_user ); 116 116 buddypress()->default_component = $old_default_component; 117 117 buddypress()->bp_nav = $old_bp_nav; … … 125 125 $u2 = self::factory()->user->create(); 126 126 $old_current_user = get_current_user_id(); 127 $this->set_current_user( $u1 );127 self::set_current_user( $u1 ); 128 128 $this->set_permalink_structure( '/%postname%/' ); 129 129 … … 150 150 151 151 // Clean up 152 $this->set_current_user( $old_current_user );152 self::set_current_user( $old_current_user ); 153 153 buddypress()->default_component = $old_default_component; 154 154 buddypress()->bp_nav = $old_bp_nav; … … 170 170 $g = self::factory()->group->create(); 171 171 $old_current_user = get_current_user_id(); 172 $this->set_current_user( $u );172 self::set_current_user( $u ); 173 173 $this->set_permalink_structure( '/%postname%/' ); 174 174 … … 188 188 189 189 // Clean up 190 $this->set_current_user( $old_current_user );190 self::set_current_user( $old_current_user ); 191 191 } 192 192 … … 195 195 $g = self::factory()->group->create(); 196 196 $old_current_user = get_current_user_id(); 197 $this->set_current_user( $u );197 self::set_current_user( $u ); 198 198 199 199 $group = groups_get_group( $g ); … … 211 211 212 212 // Clean up 213 $this->set_current_user( $old_current_user );213 self::set_current_user( $old_current_user ); 214 214 } 215 215 } -
trunk/tests/phpunit/testcases/core/nav/bpCoreNewSubnavItem.php
r13507 r13980 50 50 public function test_site_admin_only() { 51 51 $old_current_user = get_current_user_id(); 52 $this->set_current_user( 0 );52 self::set_current_user( 0 ); 53 53 54 54 $this->assertFalse( bp_core_new_subnav_item( array( … … 61 61 ) ) ); 62 62 63 $this->set_current_user( $old_current_user );63 self::set_current_user( $old_current_user ); 64 64 } 65 65 … … 110 110 $u = self::factory()->user->create(); 111 111 $old_current_user = get_current_user_id(); 112 $this->set_current_user( $u );112 self::set_current_user( $u ); 113 113 114 114 $url = bp_members_get_user_url( … … 128 128 remove_action( 'bp_setup_nav', array( $this, 'new_nav_hook' ), 0 ); 129 129 130 $this->set_current_user( $old_current_user );130 self::set_current_user( $old_current_user ); 131 131 } 132 132 } -
trunk/tests/phpunit/testcases/core/nav/bpGetNavMenuItems.php
r13433 r13980 25 25 $users = self::factory()->user->create_many( 2 ); 26 26 27 $this->set_current_user( $users[0] );27 self::set_current_user( $users[0] ); 28 28 $this->set_permalink_structure( '/%postname%/' ); 29 29 … … 51 51 $user = self::factory()->user->create(); 52 52 53 $this->set_current_user( 0 );53 self::set_current_user( 0 ); 54 54 $this->set_permalink_structure( '/%postname%/' ); 55 55 -
trunk/tests/phpunit/testcases/core/optouts.php
r12913 r13980 8 8 $old_current_user = get_current_user_id(); 9 9 10 $u1 = $this->factory->user->create();11 $this->set_current_user( $u1 );10 $u1 = self::factory()->user->create(); 11 self::set_current_user( $u1 ); 12 12 13 13 // Create a couple of optouts. … … 28 28 $this->assertEqualSets( array( $i1, $i2 ), $optouts ); 29 29 30 $this->set_current_user( $old_current_user );30 self::set_current_user( $old_current_user ); 31 31 } 32 32 … … 34 34 $old_current_user = get_current_user_id(); 35 35 36 $u1 = $this->factory->user->create();37 $this->set_current_user( $u1 );36 $u1 = self::factory()->user->create(); 37 self::set_current_user( $u1 ); 38 38 39 39 // Create an optouts. … … 48 48 $this->assertEquals( $i1, $i2 ); 49 49 50 $this->set_current_user( $old_current_user );50 self::set_current_user( $old_current_user ); 51 51 } 52 52 … … 54 54 $old_current_user = get_current_user_id(); 55 55 56 $u1 = $this->factory->user->create();57 $this->set_current_user( $u1 );56 $u1 = self::factory()->user->create(); 57 self::set_current_user( $u1 ); 58 58 59 59 $args = array( … … 72 72 $this->assertTrue( empty( $optouts ) ); 73 73 74 $this->set_current_user( $old_current_user );74 self::set_current_user( $old_current_user ); 75 75 } 76 76 … … 78 78 $old_current_user = get_current_user_id(); 79 79 80 $u1 = $this->factory->user->create();81 $this->set_current_user( $u1 );80 $u1 = self::factory()->user->create(); 81 self::set_current_user( $u1 ); 82 82 83 83 // Create a couple of optouts. … … 98 98 $this->assertEqualSets( array( $i1 ), $optouts ); 99 99 100 $this->set_current_user( $old_current_user );100 self::set_current_user( $old_current_user ); 101 101 } 102 102 … … 104 104 $old_current_user = get_current_user_id(); 105 105 106 $u1 = $this->factory->user->create();107 $this->set_current_user( $u1 );106 $u1 = self::factory()->user->create(); 107 self::set_current_user( $u1 ); 108 108 109 109 // Create a couple of optouts. … … 124 124 $this->assertEqualSets( array( $i1 ), $optouts ); 125 125 126 $this->set_current_user( $old_current_user );126 self::set_current_user( $old_current_user ); 127 127 } 128 128 … … 130 130 $old_current_user = get_current_user_id(); 131 131 132 $u1 = $this->factory->user->create();133 $this->set_current_user( $u1 );132 $u1 = self::factory()->user->create(); 133 self::set_current_user( $u1 ); 134 134 135 135 // Create a couple of optouts. … … 150 150 $this->assertEqualSets( array( $i1 ), $optouts ); 151 151 152 $this->set_current_user( $old_current_user );152 self::set_current_user( $old_current_user ); 153 153 } 154 154 … … 157 157 $old_current_user = get_current_user_id(); 158 158 159 $u1 = $this->factory->user->create();160 $this->set_current_user( $u1 );159 $u1 = self::factory()->user->create(); 160 self::set_current_user( $u1 ); 161 161 162 162 // Create an opt-out. … … 179 179 $this->assertEqualSets( array( $i1 ), $optouts ); 180 180 181 $this->set_current_user( $old_current_user );181 self::set_current_user( $old_current_user ); 182 182 } 183 183 … … 185 185 $old_current_user = get_current_user_id(); 186 186 187 $u1 = $this->factory->user->create();188 $this->set_current_user( $u1 );187 $u1 = self::factory()->user->create(); 188 self::set_current_user( $u1 ); 189 189 // Create an opt-out. 190 190 $args = array( … … 199 199 200 200 $this->assertTrue( is_wp_error( $email->validate() ) ); 201 $this->set_current_user( $old_current_user ); 202 } 203 201 self::set_current_user( $old_current_user ); 202 } 204 203 } -
trunk/tests/phpunit/testcases/core/suggestions.php
r13314 r13980 112 112 public function set_up() { 113 113 parent::set_up(); 114 $this->set_current_user( self::$current_user );114 self::set_current_user( self::$current_user ); 115 115 } 116 116 117 117 public function tear_down() { 118 self::set_current_user( self::$old_user_id ); 118 119 parent::tear_down(); 119 $this->set_current_user( self::$old_user_id );120 120 } 121 121 … … 269 269 270 270 // "alpaca red" is in the hidden group 271 $this->set_current_user( self::$user_ids['alpaca red'] );271 self::set_current_user( self::$user_ids['alpaca red'] ); 272 272 $suggestions = bp_core_get_suggestions( array( 273 273 'group_id' => self::$group_ids['hidden'], … … 289 289 290 290 // "caterpillar" is in the private group 291 $this->set_current_user( self::$user_ids['caterpillar'] );291 self::set_current_user( self::$user_ids['caterpillar'] ); 292 292 $suggestions = bp_core_get_suggestions( array( 293 293 'group_id' => self::$group_ids['private'], … … 328 328 329 329 330 $this->set_current_user( self::$user_ids['caterpillar'] );330 self::set_current_user( self::$user_ids['caterpillar'] ); 331 331 332 332 // "cat" is in the private group, so won't show up here. … … 359 359 360 360 361 $this->set_current_user( self::$user_ids['alpaca red'] );361 self::set_current_user( self::$user_ids['alpaca red'] ); 362 362 363 363 // "alpaca red" is in the hidden group, so won't show up here. -
trunk/tests/phpunit/testcases/core/template/bpUserHasAccess.php
r13433 r13980 22 22 23 23 $this->grant_bp_moderate( $users[0] ); 24 $this->set_current_user( $users[0] );24 self::set_current_user( $users[0] ); 25 25 $this->set_permalink_structure( '/%postname%/' ); 26 26 … … 33 33 $users = self::factory()->user->create_many( 2 ); 34 34 35 $this->set_current_user( $users[0] );35 self::set_current_user( $users[0] ); 36 36 $this->set_permalink_structure( '/%postname%/' ); 37 37 … … 44 44 $users = self::factory()->user->create_many( 2 ); 45 45 46 $this->set_current_user( $users[0] );46 self::set_current_user( $users[0] ); 47 47 $this->set_permalink_structure( '/%postname%/' ); 48 48 -
trunk/tests/phpunit/testcases/friends/activity.php
r12605 r13980 63 63 64 64 // Set current user to u1 to accepte the friendship 65 $this->set_current_user( $u1 );66 friends_accept_friendship( $friendship_id ); 67 68 // Reset the current user 69 $this->set_current_user( $old_user );65 self::set_current_user( $u1 ); 66 friends_accept_friendship( $friendship_id ); 67 68 // Reset the current user 69 self::set_current_user( $old_user ); 70 70 71 71 // Random activities … … 110 110 111 111 // Set current user to u1 to accept the friendship 112 $this->set_current_user( $u1 );113 friends_accept_friendship( $friendship_id ); 114 115 // Reset the current user 116 $this->set_current_user( $old_user );112 self::set_current_user( $u1 ); 113 friends_accept_friendship( $friendship_id ); 114 115 // Reset the current user 116 self::set_current_user( $old_user ); 117 117 118 118 $u1_act = bp_activity_get( array( … … 149 149 150 150 // Set current user to u1 to accepte the friendship and generate a public activity 151 $this->set_current_user( $u1 );152 friends_accept_friendship( $friendship_id ); 153 154 // Reset the current user 155 $this->set_current_user( $old_user );151 self::set_current_user( $u1 ); 152 friends_accept_friendship( $friendship_id ); 153 154 // Reset the current user 155 self::set_current_user( $old_user ); 156 156 157 157 $users[] = self::factory()->user->create(); … … 199 199 200 200 // Set current user to u1 to accept the friendship 201 $this->set_current_user( $u1 );202 friends_accept_friendship( $friendship_id ); 203 204 // Reset the current user 205 $this->set_current_user( $old_user );201 self::set_current_user( $u1 ); 202 friends_accept_friendship( $friendship_id ); 203 204 // Reset the current user 205 self::set_current_user( $old_user ); 206 206 207 207 // Delete $u1. … … 223 223 $old_user = get_current_user_id(); 224 224 $u1 = self::factory()->user->create(); 225 $this->set_current_user( $u1 );225 self::set_current_user( $u1 ); 226 226 227 227 bp_activity_remove_all_user_data( $u1 ); … … 229 229 wp_delete_user( $u1 ); 230 230 231 $this->set_current_user( $old_user );231 self::set_current_user( $old_user ); 232 232 233 233 // Remove the following lines when you implement this test. -
trunk/tests/phpunit/testcases/friends/functions.php
r13314 r13980 67 67 // accept friendship 68 68 $old_user = get_current_user_id(); 69 $this->set_current_user( $u1 );69 self::set_current_user( $u1 ); 70 70 friends_accept_friendship( friends_get_friendship_id( $u2, $u1 ) ); 71 71 … … 74 74 $this->assertEquals( array( $u3 ), $requests ); 75 75 76 $this->set_current_user( $old_user );76 self::set_current_user( $old_user ); 77 77 } 78 78 … … 124 124 // user 2 withdraws friendship 125 125 $old_user = get_current_user_id(); 126 $this->set_current_user( $u2 );126 self::set_current_user( $u2 ); 127 127 friends_withdraw_friendship( $u2, $u1 ); 128 128 … … 131 131 $this->assertEquals( array(), $requests ); 132 132 133 $this->set_current_user( $old_user );133 self::set_current_user( $old_user ); 134 134 } 135 135 … … 152 152 // user 1 rejects friendship 153 153 $old_user = get_current_user_id(); 154 $this->set_current_user( $u1 );154 self::set_current_user( $u1 ); 155 155 friends_reject_friendship( friends_get_friendship_id( $u2, $u1 ) ); 156 156 … … 159 159 $this->assertEquals( array(), $requests ); 160 160 161 $this->set_current_user( $old_user );161 self::set_current_user( $old_user ); 162 162 } 163 163 … … 198 198 199 199 $old_user = get_current_user_id(); 200 $this->set_current_user( $u1 );200 self::set_current_user( $u1 ); 201 201 202 202 $found = array(); … … 217 217 // clean up 218 218 $GLOBALS['members_template'] = null; 219 $this->set_current_user( $old_user );219 self::set_current_user( $old_user ); 220 220 } 221 221 … … 300 300 * @see bp_friends_filter_user_query_populate_extras() 301 301 */ 302 $this->set_current_user( $u1 );302 self::set_current_user( $u1 ); 303 303 $this->go_to( bp_get_members_directory_permalink() ); 304 304 ob_start(); … … 315 315 * properly. 316 316 */ 317 $this->set_current_user( $u2 );317 self::set_current_user( $u2 ); 318 318 friends_accept_friendship( friends_get_friendship_id( $u1, $u2 ) ); 319 319 320 320 // Afterwards, user 1 decides to cancel friendship. 321 $this->set_current_user( $u1 );321 self::set_current_user( $u1 ); 322 322 friends_remove_friend( $u1, $u2 ); 323 323 … … 325 325 $this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 326 326 327 $this->set_current_user( $old_user );327 self::set_current_user( $old_user ); 328 328 } 329 329 -
trunk/tests/phpunit/testcases/friends/notifications.php
r13314 r13980 12 12 parent::set_up(); 13 13 $this->current_user = get_current_user_id(); 14 $this->set_current_user( self::factory()->user->create() );14 self::set_current_user( self::factory()->user->create() ); 15 15 16 16 $this->friend = self::factory()->user->create(); … … 19 19 20 20 public function tear_down() { 21 self::set_current_user( $this->current_user ); 21 22 parent::tear_down(); 22 $this->set_current_user( $this->current_user );23 23 } 24 24 -
trunk/tests/phpunit/testcases/groups/activity.php
r13870 r13980 105 105 $old_user = get_current_user_id(); 106 106 $u = self::factory()->user->create(); 107 $this->set_current_user( $u );107 self::set_current_user( $u ); 108 108 109 109 $group = self::factory()->group->create_and_get(); … … 127 127 $this->assertSame( $expected, $a['activities'][0]->action ); 128 128 129 $this->set_current_user( $old_user );129 self::set_current_user( $old_user ); 130 130 } 131 131 … … 137 137 $old_user = get_current_user_id(); 138 138 $u = self::factory()->user->create(); 139 $this->set_current_user( $u );139 self::set_current_user( $u ); 140 140 141 141 $group = self::factory()->group->create_and_get(); … … 159 159 $this->assertSame( $expected, $a['activities'][0]->action ); 160 160 161 $this->set_current_user( $old_user );161 self::set_current_user( $old_user ); 162 162 } 163 163 … … 169 169 $old_user = get_current_user_id(); 170 170 $u = self::factory()->user->create(); 171 $this->set_current_user( $u );171 self::set_current_user( $u ); 172 172 173 173 $group = self::factory()->group->create_and_get(); … … 192 192 $this->assertSame( $expected, $a['activities'][0]->action ); 193 193 194 $this->set_current_user( $old_user );194 self::set_current_user( $old_user ); 195 195 } 196 196 … … 202 202 $old_user = get_current_user_id(); 203 203 $u = self::factory()->user->create(); 204 $this->set_current_user( $u );204 self::set_current_user( $u ); 205 205 206 206 $group = self::factory()->group->create_and_get(); … … 224 224 $this->assertSame( $expected, $a['activities'][0]->action ); 225 225 226 $this->set_current_user( $old_user );226 self::set_current_user( $old_user ); 227 227 } 228 228 … … 325 325 ) ); 326 326 327 $this->set_current_user( $u1 );327 self::set_current_user( $u1 ); 328 328 if ( bp_has_activities( array( 'in' => $a ) ) ) { 329 329 while ( bp_activities() ) : bp_the_activity(); … … 333 333 } 334 334 335 $this->set_current_user( $u2 );335 self::set_current_user( $u2 ); 336 336 if ( bp_has_activities( array( 'in' => $a ) ) ) { 337 337 while ( bp_activities() ) : bp_the_activity(); … … 341 341 } 342 342 343 $this->set_current_user( $old_user );343 self::set_current_user( $old_user ); 344 344 } 345 345 … … 363 363 $original_user = bp_loggedin_user_id(); 364 364 365 $this->set_current_user( $u1 );365 self::set_current_user( $u1 ); 366 366 367 367 $g = self::factory()->group->create(); … … 395 395 396 396 // User can delete his own activity. 397 $this->set_current_user( $u2 );397 self::set_current_user( $u2 ); 398 398 $this->assertTrue( bp_activity_user_can_delete( $activity ) ); 399 399 400 400 // Activity from site admins can't be deleted by non site admins. 401 $this->set_current_user( $u2 );401 self::set_current_user( $u2 ); 402 402 $this->assertFalse( bp_activity_user_can_delete( $activity_b ) ); 403 403 404 404 // Activity from site admins can be deleted by other site admins. 405 405 $site_admin = self::factory()->user->create( array( 'role' => 'administrator' ) ); 406 $this->set_current_user( $site_admin );406 self::set_current_user( $site_admin ); 407 407 $this->assertTrue( bp_activity_user_can_delete( $activity_b ) ); 408 408 409 409 // Group creator can delete activity. 410 $this->set_current_user( $u1 );410 self::set_current_user( $u1 ); 411 411 $this->assertTrue( bp_activity_user_can_delete( $activity ) ); 412 412 413 413 // Logged-out user can't delete activity. 414 $this->set_current_user( 0 );414 self::set_current_user( 0 ); 415 415 $this->assertFalse( bp_activity_user_can_delete( $activity ) ); 416 416 417 417 // Misc user can't delete activity. 418 418 $misc_user = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 419 $this->set_current_user( $misc_user );419 self::set_current_user( $misc_user ); 420 420 $this->assertFalse( bp_activity_user_can_delete( $activity ) ); 421 421 … … 423 423 $misc_user_2 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 424 424 self::add_user_to_group( $misc_user_2, $g ); 425 $this->set_current_user( $misc_user_2 );425 self::set_current_user( $misc_user_2 ); 426 426 $this->assertFalse( bp_activity_user_can_delete( $activity ) ); 427 427 … … 429 429 $misc_user_3 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 430 430 self::add_user_to_group( $misc_user_3, $g, [ 'is_mod' => true ] ); 431 $this->set_current_user( $misc_user_3 );431 self::set_current_user( $misc_user_3 ); 432 432 $this->assertTrue( bp_activity_user_can_delete( $activity ) ); 433 433 … … 435 435 $misc_user_4 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 436 436 self::add_user_to_group( $misc_user_4, $g, [ 'is_admin' => true ] ); 437 $this->set_current_user( $misc_user_4 );437 self::set_current_user( $misc_user_4 ); 438 438 $this->assertTrue( bp_activity_user_can_delete( $activity ) ); 439 439 440 $this->set_current_user( $original_user );440 self::set_current_user( $original_user ); 441 441 } 442 442 … … 449 449 $original_user = bp_loggedin_user_id(); 450 450 451 $this->set_current_user( $u1 );451 self::set_current_user( $u1 ); 452 452 453 453 $g = self::factory()->group->create(); … … 486 486 self::add_user_to_group( $u2, $g, [ 'is_admin' => true ] ); 487 487 488 $this->set_current_user( $u2 );488 self::set_current_user( $u2 ); 489 489 $this->assertFalse( bp_activity_user_can_delete( $activity ), 'Group Admins or Mods shouldn not be able to delete activities that are not attached to a group' ); 490 490 … … 500 500 $this->assertFalse( bp_activity_user_can_delete( $activity ), 'Group Admins or Mods should not be able to delete another group activities.' ); 501 501 502 $this->set_current_user( $original_user );502 self::set_current_user( $original_user ); 503 503 } 504 504 } -
trunk/tests/phpunit/testcases/groups/class-bp-group-extension.php
r13507 r13980 16 16 17 17 public function tear_down() { 18 $this->set_permalink_structure( $this->permalink_structure ); 18 19 parent::tear_down(); 19 $this->set_permalink_structure( $this->permalink_structure );20 20 } 21 21 … … 241 241 $this->go_to( bp_get_group_url( $g_obj ) ); 242 242 243 $this->set_current_user( 0 );243 self::set_current_user( 0 ); 244 244 245 245 $e = new BPTest_Group_Extension_Inferred_Access_Settings_EnableNavItem_True(); … … 251 251 $this->assertFalse( $e2->user_can_visit() ); 252 252 253 $this->set_current_user( $old_current_user );253 self::set_current_user( $old_current_user ); 254 254 } 255 255 … … 260 260 $this->set_permalink_structure( '/%postname%/' ); 261 261 $old_current_user = get_current_user_id(); 262 $this->set_current_user( 0 );262 self::set_current_user( 0 ); 263 263 264 264 $g = self::factory()->group->create( array( … … 292 292 $this->assertFalse( $e6->user_can_visit() ); 293 293 294 $this->set_current_user( $old_current_user );294 self::set_current_user( $old_current_user ); 295 295 } 296 296 … … 307 307 $u = self::factory()->user->create(); 308 308 $old_current_user = get_current_user_id(); 309 $this->set_current_user( $u );309 self::set_current_user( $u ); 310 310 311 311 $this->go_to( bp_get_group_url( $g_obj ) ); … … 335 335 $this->assertFalse( $e6->user_can_visit() ); 336 336 337 $this->set_current_user( $old_current_user );337 self::set_current_user( $old_current_user ); 338 338 } 339 339 … … 350 350 $u = self::factory()->user->create(); 351 351 $old_current_user = get_current_user_id(); 352 $this->set_current_user( $u );352 self::set_current_user( $u ); 353 353 354 354 $this->add_user_to_group( $u, $g ); … … 380 380 $this->assertFalse( $e6->user_can_visit() ); 381 381 382 $this->set_current_user( $old_current_user );382 self::set_current_user( $old_current_user ); 383 383 } 384 384 … … 395 395 $u = self::factory()->user->create(); 396 396 $old_current_user = get_current_user_id(); 397 $this->set_current_user( $u );397 self::set_current_user( $u ); 398 398 399 399 $m = $this->add_user_to_group( $u, $g ); … … 427 427 $this->assertFalse( $e6->user_can_visit() ); 428 428 429 $this->set_current_user( $old_current_user );429 self::set_current_user( $old_current_user ); 430 430 } 431 431 … … 442 442 $u = self::factory()->user->create(); 443 443 $old_current_user = get_current_user_id(); 444 $this->set_current_user( $u );444 self::set_current_user( $u ); 445 445 446 446 $m = $this->add_user_to_group( $u, $g ); … … 474 474 $this->assertFalse( $e6->user_can_visit() ); 475 475 476 $this->set_current_user( $old_current_user );476 self::set_current_user( $old_current_user ); 477 477 } 478 478 … … 488 488 489 489 $old_current_user = get_current_user_id(); 490 $this->set_current_user( 0 );490 self::set_current_user( 0 ); 491 491 492 492 $this->go_to( bp_get_group_url( $g_obj ) ); … … 516 516 $this->assertFalse( $e6->user_can_visit() ); 517 517 518 $this->set_current_user( $old_current_user );518 self::set_current_user( $old_current_user ); 519 519 } 520 520 … … 530 530 531 531 $old_current_user = get_current_user_id(); 532 $this->set_current_user( 0 );532 self::set_current_user( 0 ); 533 533 534 534 $this->go_to( bp_get_group_url( $g_obj ) ); … … 558 558 $this->assertFalse( $e6->user_can_see_nav_item() ); 559 559 560 $this->set_current_user( $old_current_user );560 self::set_current_user( $old_current_user ); 561 561 } 562 562 … … 573 573 $u = self::factory()->user->create(); 574 574 $old_current_user = get_current_user_id(); 575 $this->set_current_user( $u );575 self::set_current_user( $u ); 576 576 577 577 $this->go_to( bp_get_group_url( $g_obj ) ); … … 601 601 $this->assertFalse( $e6->user_can_see_nav_item() ); 602 602 603 $this->set_current_user( $old_current_user );603 self::set_current_user( $old_current_user ); 604 604 } 605 605 … … 616 616 $u = self::factory()->user->create(); 617 617 $old_current_user = get_current_user_id(); 618 $this->set_current_user( $u );618 self::set_current_user( $u ); 619 619 620 620 $this->add_user_to_group( $u, $g ); … … 646 646 $this->assertFalse( $e6->user_can_see_nav_item() ); 647 647 648 $this->set_current_user( $old_current_user );648 self::set_current_user( $old_current_user ); 649 649 } 650 650 … … 661 661 $u = self::factory()->user->create(); 662 662 $old_current_user = get_current_user_id(); 663 $this->set_current_user( $u );663 self::set_current_user( $u ); 664 664 665 665 $this->add_user_to_group( $u, $g ); … … 693 693 $this->assertFalse( $e6->user_can_see_nav_item() ); 694 694 695 $this->set_current_user( $old_current_user );695 self::set_current_user( $old_current_user ); 696 696 } 697 697 … … 708 708 $u = self::factory()->user->create(); 709 709 $old_current_user = get_current_user_id(); 710 $this->set_current_user( $u );710 self::set_current_user( $u ); 711 711 712 712 $this->add_user_to_group( $u, $g ); … … 740 740 $this->assertFalse( $e6->user_can_see_nav_item() ); 741 741 742 $this->set_current_user( $old_current_user );742 self::set_current_user( $old_current_user ); 743 743 } 744 744 -
trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php
r13414 r13980 976 976 977 977 // Instantiate group object. 978 $this->set_current_user( $u );978 self::set_current_user( $u ); 979 979 $group = new BP_Groups_Group( $g ); 980 980 … … 982 982 $this->assertTrue( ! empty( $group->is_member ) ); 983 983 984 $this->set_current_user( $this->old_current_user );984 self::set_current_user( $this->old_current_user ); 985 985 } 986 986 … … 1470 1470 1471 1471 $old_user = get_current_user_id(); 1472 $this->set_current_user( 0 );1472 self::set_current_user( 0 ); 1473 1473 1474 1474 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 1475 1475 1476 $this->set_current_user( $old_user );1476 self::set_current_user( $old_user ); 1477 1477 } 1478 1478 … … 1501 1501 1502 1502 $old_user = get_current_user_id(); 1503 $this->set_current_user( $u );1503 self::set_current_user( $u ); 1504 1504 1505 1505 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 1506 1506 1507 $this->set_current_user( $old_user );1507 self::set_current_user( $old_user ); 1508 1508 } 1509 1509 … … 1533 1533 1534 1534 $old_user = get_current_user_id(); 1535 $this->set_current_user( $u );1535 self::set_current_user( $u ); 1536 1536 1537 1537 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 1538 1538 1539 $this->set_current_user( $old_user );1539 self::set_current_user( $old_user ); 1540 1540 } 1541 1541 … … 1573 1573 1574 1574 $old_user = get_current_user_id(); 1575 $this->set_current_user( $u );1575 self::set_current_user( $u ); 1576 1576 1577 1577 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 1578 1578 1579 $this->set_current_user( $old_user );1579 self::set_current_user( $old_user ); 1580 1580 } 1581 1581 … … 1610 1610 1611 1611 $old_user = get_current_user_id(); 1612 $this->set_current_user( $u );1612 self::set_current_user( $u ); 1613 1613 1614 1614 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 1615 1615 1616 $this->set_current_user( $old_user );1616 self::set_current_user( $old_user ); 1617 1617 } 1618 1618 … … 1648 1648 1649 1649 $old_user = get_current_user_id(); 1650 $this->set_current_user( $u );1650 self::set_current_user( $u ); 1651 1651 1652 1652 $this->assertEquals( $expected, BP_Groups_Group::get_group_extras( $paged_groups, $group_ids ) ); 1653 1653 1654 $this->set_current_user( $old_user );1654 self::set_current_user( $old_user ); 1655 1655 } 1656 1656 … … 2438 2438 public function test_get_return_ids_only() { 2439 2439 $now = time(); 2440 $g1 = $this->factory->group->create( array(2440 $g1 = self::factory()->group->create( array( 2441 2441 'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60 ), 2442 2442 ) ); 2443 $g2 = $this->factory->group->create( array(2443 $g2 = self::factory()->group->create( array( 2444 2444 'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*2 ), 2445 2445 ) ); 2446 $g3 = $this->factory->group->create( array(2446 $g3 = self::factory()->group->create( array( 2447 2447 'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*3 ), 2448 2448 ) ); … … 2454 2454 $this->assertSame( array( $g1, $g2, $g3 ), $groups['groups'] ); 2455 2455 } 2456 2457 2456 } 2458 2457 -
trunk/tests/phpunit/testcases/groups/class-bp-groups-member.php
r13874 r13980 15 15 16 16 public function tear_down() { 17 $this->set_permalink_structure( $this->permalink_structure ); 17 18 parent::tear_down(); 18 $this->set_permalink_structure( $this->permalink_structure );19 19 } 20 20 … … 222 222 $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_siteadmin ) ); 223 223 // Falling back to current user 224 $this->set_current_user( $u_members );224 self::set_current_user( $u_members ); 225 225 $this->assertTrue( bp_groups_user_can_send_invites( $g, null ) ); 226 226 … … 233 233 $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_siteadmin ) ); 234 234 // Falling back to current user 235 $this->set_current_user( $u_members );235 self::set_current_user( $u_members ); 236 236 $this->assertFalse( bp_groups_user_can_send_invites( $g, null ) ); 237 $this->set_current_user( $u_mods );237 self::set_current_user( $u_mods ); 238 238 $this->assertTrue( bp_groups_user_can_send_invites( $g, null ) ); 239 239 … … 246 246 $this->assertTrue( bp_groups_user_can_send_invites( $g, $u_siteadmin ) ); 247 247 // Falling back to current user 248 $this->set_current_user( $u_mods );248 self::set_current_user( $u_mods ); 249 249 $this->assertFalse( bp_groups_user_can_send_invites( $g, null ) ); 250 $this->set_current_user( $u_admins );250 self::set_current_user( $u_admins ); 251 251 $this->assertTrue( bp_groups_user_can_send_invites( $g, null ) ); 252 252 … … 264 264 $this->assertTrue( bp_groups_user_can_send_invites( null, $u_mods ) ); 265 265 266 $this->set_current_user( $old_current_user );266 self::set_current_user( $old_current_user ); 267 267 } 268 268 … … 680 680 $g = self::factory()->group->create(); 681 681 $old_current_user = get_current_user_id(); 682 $this->set_current_user( $u1 );682 self::set_current_user( $u1 ); 683 683 684 684 groups_join_group( $g ); 685 685 $membership_id = groups_is_user_member( $u1, $g ); 686 686 $this->assertTrue( is_numeric( $membership_id ) && $membership_id > 0 ); 687 $this->set_current_user( $old_current_user );687 self::set_current_user( $old_current_user ); 688 688 } 689 689 … … 754 754 755 755 $before = groups_get_total_member_count( $g ); 756 $this->set_current_user( $u2 );756 self::set_current_user( $u2 ); 757 757 groups_leave_group( $g, $u2 ); 758 758 $after = groups_get_total_member_count( $g ); 759 759 760 760 $this->assertEquals( $before - 1, $after ); 761 $this->set_current_user( $old_current_user );761 self::set_current_user( $old_current_user ); 762 762 } 763 763 … … 774 774 775 775 $before = groups_get_total_member_count( $g ); 776 $this->set_current_user( $u2 );776 self::set_current_user( $u2 ); 777 777 groups_leave_group( $g ); 778 778 $after = groups_get_total_member_count( $g ); 779 779 780 780 $this->assertEquals( $before - 1, $after ); 781 $this->set_current_user( $old_current_user );781 self::set_current_user( $old_current_user ); 782 782 } 783 783 … … 794 794 795 795 $before = groups_get_total_member_count( $g ); 796 $this->set_current_user( $u1 );796 self::set_current_user( $u1 ); 797 797 groups_leave_group( $g, $u2 ); 798 798 $after = groups_get_total_member_count( $g ); 799 799 800 800 $this->assertEquals( $before - 1, $after ); 801 $this->set_current_user( $old_current_user );801 self::set_current_user( $old_current_user ); 802 802 } 803 803 … … 816 816 817 817 $before = groups_get_total_member_count( $g ); 818 $this->set_current_user( $u1 );818 self::set_current_user( $u1 ); 819 819 groups_leave_group( $g, $u2 ); 820 820 $after = groups_get_total_member_count( $g ); 821 821 822 822 $this->assertEquals( $before - 1, $after ); 823 $this->set_current_user( $old_current_user );823 self::set_current_user( $old_current_user ); 824 824 } 825 825 … … 836 836 837 837 $before = groups_get_total_member_count( $g ); 838 $this->set_current_user( $u1 );838 self::set_current_user( $u1 ); 839 839 groups_leave_group( $g, $u1 ); 840 840 $after = groups_get_total_member_count( $g ); 841 841 842 842 $this->assertEquals( $before, $after ); 843 $this->set_current_user( $old_current_user );843 self::set_current_user( $old_current_user ); 844 844 } 845 845 … … 858 858 859 859 $before = groups_get_total_member_count( $g ); 860 $this->set_current_user( $u1 );860 self::set_current_user( $u1 ); 861 861 groups_leave_group( $g, $u1 ); 862 862 $after = groups_get_total_member_count( $g ); 863 863 864 864 $this->assertEquals( $before - 1, $after ); 865 $this->set_current_user( $old_current_user );865 self::set_current_user( $old_current_user ); 866 866 } 867 867 … … 935 935 ) ); 936 936 937 $this->set_current_user( $u2 );937 self::set_current_user( $u2 ); 938 938 $groups = groups_get_invites_for_user(); 939 939 $this->assertEqualSets( array( $g1, $g2, $g3 ), wp_list_pluck( $groups['groups'], 'id' ) ); 940 940 941 $this->set_current_user( $old_current_user );941 self::set_current_user( $old_current_user ); 942 942 } 943 943 -
trunk/tests/phpunit/testcases/groups/functions.php
r13357 r13980 61 61 62 62 // Set the current user so the leave group request goes through. 63 $this->set_current_user( $u2 );63 self::set_current_user( $u2 ); 64 64 groups_leave_group( $g1, $u2 ); 65 65 $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) ); … … 79 79 80 80 // Fool the admin check 81 $this->set_current_user( $u1 );81 self::set_current_user( $u1 ); 82 82 buddypress()->is_item_admin = true; 83 83 … … 100 100 101 101 // Fool the admin check 102 $this->set_current_user( $u1 );102 self::set_current_user( $u1 ); 103 103 buddypress()->is_item_admin = true; 104 104 … … 140 140 141 141 $current_user = bp_loggedin_user_id(); 142 $this->set_current_user( $u2 );142 self::set_current_user( $u2 ); 143 143 144 144 $g = self::factory()->group->create( array( 'status' => 'private' ) ); … … 152 152 $this->assertEquals( 1, bp_get_user_meta( $u1, 'total_group_count', true ) ); 153 153 154 $this->set_current_user( $current_user );154 self::set_current_user( $current_user ); 155 155 } 156 156 … … 168 168 169 169 // Fool the admin check 170 $this->set_current_user( $u1 );170 self::set_current_user( $u1 ); 171 171 buddypress()->is_item_admin = true; 172 172 … … 227 227 228 228 // Fool the admin check 229 $this->set_current_user( $u1 );229 self::set_current_user( $u1 ); 230 230 buddypress()->is_item_admin = true; 231 231 … … 248 248 249 249 // Fool the admin check 250 $this->set_current_user( $u1 );250 self::set_current_user( $u1 ); 251 251 buddypress()->is_item_admin = true; 252 252 … … 311 311 312 312 // Fool the admin check 313 $this->set_current_user( $u1 );313 self::set_current_user( $u1 ); 314 314 buddypress()->is_item_admin = true; 315 315 … … 382 382 ) ); 383 383 384 $this->set_current_user( $u1 );384 self::set_current_user( $u1 ); 385 385 $g1 = self::factory()->group->create(); 386 386 … … 389 389 $this->assertEquals( 2, groups_get_total_member_count( $g1 ) ); 390 390 391 $this->set_current_user( $current_user );391 self::set_current_user( $current_user ); 392 392 } 393 393 -
trunk/tests/phpunit/testcases/groups/functions/get-group.php
r13335 r13980 36 36 */ 37 37 public function test_bp_get_group_with_id() { 38 $g = $this->factory->group->create();38 $g = self::factory()->group->create(); 39 39 40 40 $this->assertSame( $g, bp_get_group( $g )->id ); … … 48 48 public function test_bp_get_group_with_slug() { 49 49 $slug = 'test-group'; 50 $g = $this->factory->group->create( array( 'slug' => $slug ) );50 $g = self::factory()->group->create( array( 'slug' => $slug ) ); 51 51 $g1 = bp_get_group( $slug ); 52 52 … … 64 64 */ 65 65 public function test_bp_get_group_with_object() { 66 $g = $this->factory->group->create_and_get();66 $g = self::factory()->group->create_and_get(); 67 67 68 68 $this->assertSame( $g->id, bp_get_group( $g )->id ); … … 73 73 */ 74 74 public function test_bp_get_group_from_groups_template() { 75 $g = $this->factory->group->create( array( 'status' => 'private' ) );75 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 76 76 77 77 if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) { … … 90 90 public function test_bp_get_group_from_current_group() { 91 91 $bp = buddypress(); 92 $g = $this->factory->group->create_and_get( array( 'name' => 'foo' ) );92 $g = self::factory()->group->create_and_get( array( 'name' => 'foo' ) ); 93 93 94 94 // Set the current group. -
trunk/tests/phpunit/testcases/groups/functions/groupsCreateGroup.php
r11739 r13980 22 22 public function test_should_respect_creator_id() { 23 23 $old_user_id = bp_loggedin_user_id(); 24 $this->set_current_user( self::$user_id );24 self::set_current_user( self::$user_id ); 25 25 26 26 $group_id = groups_create_group( array( … … 31 31 $group = groups_get_group( $group_id ); 32 32 33 $this->set_current_user( $old_user_id );33 self::set_current_user( $old_user_id ); 34 34 35 35 $this->assertSame( self::$user_id + 1, $group->creator_id ); … … 41 41 public function test_creator_id_should_be_fall_back_to_loggedin_user_for_new_group() { 42 42 $old_user_id = bp_loggedin_user_id(); 43 $this->set_current_user( self::$user_id );43 self::set_current_user( self::$user_id ); 44 44 45 45 $group_id = groups_create_group( array( … … 49 49 $group = groups_get_group( $group_id ); 50 50 51 $this->set_current_user( $old_user_id );51 self::set_current_user( $old_user_id ); 52 52 53 53 $this->assertSame( self::$user_id, $group->creator_id ); … … 63 63 64 64 $old_user_id = bp_loggedin_user_id(); 65 $this->set_current_user( self::$user_id );65 self::set_current_user( self::$user_id ); 66 66 67 67 $group_id = groups_create_group( array( … … 71 71 $group = groups_get_group( $group_id ); 72 72 73 $this->set_current_user( $old_user_id );73 self::set_current_user( $old_user_id ); 74 74 75 75 $this->assertSame( self::$user_id + 1, $group->creator_id ); -
trunk/tests/phpunit/testcases/groups/notifications.php
r13873 r13980 14 14 parent::set_up(); 15 15 $this->current_user = get_current_user_id(); 16 $this->set_current_user( self::factory()->user->create() );16 self::set_current_user( self::factory()->user->create() ); 17 17 18 18 $this->requesting_user_id = self::factory()->user->create(); … … 22 22 23 23 public function tear_down() { 24 self::set_current_user( $this->current_user ); 25 24 26 parent::tear_down(); 25 $this->set_current_user( $this->current_user );26 27 } 27 28 … … 299 300 $this->assertEmpty( $u1_notifications ); 300 301 } 301 302 302 } -
trunk/tests/phpunit/testcases/groups/template.php
r13503 r13980 903 903 // Fool the admin check 904 904 $old_user = get_current_user_id(); 905 $this->set_current_user( $u2 );905 self::set_current_user( $u2 ); 906 906 buddypress()->is_item_admin = true; 907 907 groups_ban_member( $u1, $g2 ); 908 908 909 909 // Start the groups loop 910 $this->set_current_user( $u1 );910 self::set_current_user( $u1 ); 911 911 if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); 912 912 $found[] = bp_group_is_user_banned(); … … 919 919 // Clean up 920 920 $GLOBALS['groups_template'] = null; 921 $this->set_current_user( $old_user );921 self::set_current_user( $old_user ); 922 922 } 923 923 … … 949 949 // Fool the admin check 950 950 $old_user = get_current_user_id(); 951 $this->set_current_user( $u2 );951 self::set_current_user( $u2 ); 952 952 buddypress()->is_item_admin = true; 953 953 groups_ban_member( $u1, $g2 ); … … 966 966 967 967 // Clean up 968 $this->set_current_user( $old_user );968 self::set_current_user( $old_user ); 969 969 } 970 970 … … 973 973 */ 974 974 public function test_bp_group_is_forum_enabled() { 975 $g1 = $this->factory->group->create( array( 'enable_forum' => 0 ) );976 $g2 = $this->factory->group->create( array( 'enable_forum' => 1 ) );975 $g1 = self::factory()->group->create( array( 'enable_forum' => 0 ) ); 976 $g2 = self::factory()->group->create( array( 'enable_forum' => 1 ) ); 977 977 978 978 $this->assertFalse( bp_group_is_forum_enabled( $g1 ) ); … … 1005 1005 */ 1006 1006 public function test_bp_bp_get_group_form_action() { 1007 $g = $this->factory->group->create();1007 $g = self::factory()->group->create(); 1008 1008 $p = 'members'; 1009 1009 $url = bp_get_group_url( … … 1021 1021 */ 1022 1022 public function test_bp_get_group_member_count_0_members() { 1023 $u = $this->factory->user->create();1024 $g = $this->factory->group->create( array( 'creator_id' => $u ) );1023 $u = self::factory()->user->create(); 1024 $g = self::factory()->group->create( array( 'creator_id' => $u ) ); 1025 1025 1026 1026 // Fake the current group. … … 1038 1038 */ 1039 1039 public function test_bp_get_group_member_count_1_member() { 1040 $g = $this->factory->group->create();1040 $g = self::factory()->group->create(); 1041 1041 1042 1042 // Fake the current group. … … 1051 1051 */ 1052 1052 public function test_bp_get_group_member_count_2_members() { 1053 $u1 = $this->factory->user->create();1054 $u2 = $this->factory->user->create();1055 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) );1053 $u1 = self::factory()->user->create(); 1054 $u2 = self::factory()->user->create(); 1055 $g = self::factory()->group->create( array( 'creator_id' => $u1 ) ); 1056 1056 1057 1057 $this->add_user_to_group( $u2, $g ); -
trunk/tests/phpunit/testcases/groups/template/bpGroupStatusMessage.php
r13314 r13980 12 12 parent::set_up(); 13 13 $this->current_user = bp_loggedin_user_id(); 14 $this->set_current_user( 0 );14 self::set_current_user( 0 ); 15 15 16 16 if ( isset( $GLOBALS['groups_template'] ) ) { … … 20 20 21 21 public function tear_down() { 22 $this->set_current_user( $this->current_user );22 self::set_current_user( $this->current_user ); 23 23 if ( $this->groups_template ) { 24 24 $GLOBALS['groups_template'] = $this->groups_template; … … 35 35 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 36 36 37 $this->set_current_user( $users[0] );37 self::set_current_user( $users[0] ); 38 38 39 39 groups_invite_user( array( … … 61 61 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 62 62 63 $this->set_current_user( $u );63 self::set_current_user( $u ); 64 64 65 65 if ( bp_has_groups( array( 'include' => array( $g ) ) ) ) { … … 98 98 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 99 99 100 $this->set_current_user( $u );100 self::set_current_user( $u ); 101 101 102 102 groups_send_membership_request( array( … … 123 123 $g = self::factory()->group->create( array( 'status' => 'hidden' ) ); 124 124 125 $this->set_current_user( $u );125 self::set_current_user( $u ); 126 126 127 127 $group = groups_get_group( $g ); … … 140 140 $groups = self::factory()->group->create_many( 2, array( 'status' => 'private' ) ); 141 141 142 $this->set_current_user( $u );142 self::set_current_user( $u ); 143 143 144 144 // Fake the current group. -
trunk/tests/phpunit/testcases/groups/template/group-is-visible.php
r13414 r13980 25 25 26 26 public function test_bp_group_is_visible_no_member() { 27 $g = $this->factory->group->create( array( 'status' => 'private' ) );27 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 28 28 29 29 $this->assertFalse( bp_group_is_visible( $g ) ); … … 31 31 32 32 public function test_bp_group_is_visible_regular_member() { 33 $g = $this->factory->group->create( array( 'status' => 'private' ) );34 $u = $this->factory->user->create();33 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 34 $u = self::factory()->user->create(); 35 35 36 $this->set_current_user( $u );36 self::set_current_user( $u ); 37 37 38 38 $this->assertFalse( bp_group_is_visible( $g ) ); … … 40 40 41 41 public function test_bp_group_is_visible_regular_member_from_group() { 42 $g = $this->factory->group->create( array( 'status' => 'private' ) );43 $u = $this->factory->user->create();42 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 43 $u = self::factory()->user->create(); 44 44 45 $this->set_current_user( $u );45 self::set_current_user( $u ); 46 46 47 47 $this->add_user_to_group( $u, $g ); … … 51 51 52 52 public function test_bp_group_is_visible_invalid_group() { 53 $u = $this->factory->user->create();53 $u = self::factory()->user->create(); 54 54 55 55 // Empty the current group. … … 57 57 $GLOBALS['groups_template']->group = null; 58 58 59 $this->set_current_user( $u );59 self::set_current_user( $u ); 60 60 61 61 $this->assertFalse( bp_group_is_visible() ); … … 63 63 64 64 public function test_bp_group_is_visible_admin() { 65 $g = $this->factory->group->create( array( 'status' => 'private' ) );66 $u = $this->factory->user->create( array( 'role' => 'administrator' ) );65 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 66 $u = self::factory()->user->create( array( 'role' => 'administrator' ) ); 67 67 68 $this->set_current_user( $u );68 self::set_current_user( $u ); 69 69 70 70 $this->assertTrue( bp_group_is_visible( $g ) ); … … 72 72 73 73 public function test_bp_group_is_visible_using_user_id() { 74 $g = $this->factory->group->create( array( 'status' => 'hidden' ) );75 $u = $this->factory->user->create();74 $g = self::factory()->group->create( array( 'status' => 'hidden' ) ); 75 $u = self::factory()->user->create(); 76 76 77 77 $this->add_user_to_group( $u, $g ); … … 81 81 82 82 public function test_bp_group_is_not_visible_using_user_id() { 83 $g = $this->factory->group->create( array( 'status' => 'private' ) );84 $u = $this->factory->user->create();83 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 84 $u = self::factory()->user->create(); 85 85 86 86 $this->assertFalse( bp_group_is_visible( $g, $u ) ); … … 90 90 $slug = 'test-group'; 91 91 92 $this->factory->group->create(92 self::factory()->group->create( 93 93 array( 94 94 'status' => 'private', … … 97 97 ); 98 98 99 $u = $this->factory->user->create( array( 'role' => 'administrator' ) );99 $u = self::factory()->user->create( array( 'role' => 'administrator' ) ); 100 100 101 $this->set_current_user( $u );101 self::set_current_user( $u ); 102 102 103 103 $this->assertTrue( bp_group_is_visible( $slug ) ); … … 105 105 106 106 public function test_bp_group_is_visible_from_current_group() { 107 $g = $this->factory->group->create( array( 'status' => 'private' ) );108 $u = $this->factory->user->create( array( 'role' => 'administrator' ) );107 $g = self::factory()->group->create( array( 'status' => 'private' ) ); 108 $u = self::factory()->user->create( array( 'role' => 'administrator' ) ); 109 109 110 110 // Fake the current group. … … 112 112 $GLOBALS['groups_template']->group = groups_get_group( $g ); 113 113 114 $this->set_current_user( $u );114 self::set_current_user( $u ); 115 115 116 116 $this->assertTrue( bp_group_is_visible() ); -
trunk/tests/phpunit/testcases/groups/user_can.php
r12440 r13980 7 7 8 8 public function test_user_can_join_public_group() { 9 $g1 = $this->factory->group->create( array(10 'status' => 'public' 11 ) ); 12 $u1 = $this->factory->user->create();9 $g1 = self::factory()->group->create( array( 10 'status' => 'public' 11 ) ); 12 $u1 = self::factory()->user->create(); 13 13 14 14 $this->assertTrue( bp_user_can( $u1, 'groups_join_group', array( 'group_id' => $g1 ) ) ); … … 16 16 17 17 public function test_user_cannot_join_public_group_if_already_member() { 18 $g1 = $this->factory->group->create( array(19 'status' => 'public' 20 ) ); 21 $u1 = $this->factory->user->create();18 $g1 = self::factory()->group->create( array( 19 'status' => 'public' 20 ) ); 21 $u1 = self::factory()->user->create(); 22 22 $this->add_user_to_group( $u1, $g1 ); 23 23 … … 33 33 } 34 34 35 $g1 = $this->factory->group->create( array(36 'status' => 'public' 37 ) ); 38 $u1 = $this->factory->user->create();35 $g1 = self::factory()->group->create( array( 36 'status' => 'public' 37 ) ); 38 $u1 = self::factory()->user->create(); 39 39 $this->add_user_to_group( $u1, $g1 ); 40 40 … … 46 46 47 47 public function test_user_cannot_join_private_group() { 48 $g1 = $this->factory->group->create( array(49 'status' => 'private' 50 ) ); 51 $u1 = $this->factory->user->create();48 $g1 = self::factory()->group->create( array( 49 'status' => 'private' 50 ) ); 51 $u1 = self::factory()->user->create(); 52 52 53 53 $this->assertFalse( bp_user_can( $u1, 'groups_join_group', array( 'group_id' => $g1 ) ) ); … … 55 55 56 56 public function test_user_cannot_join_group_if_banned() { 57 $g1 = $this->factory->group->create( array(58 'status' => 'public' 59 ) ); 60 $u1 = $this->factory->user->create();57 $g1 = self::factory()->group->create( array( 58 'status' => 'public' 59 ) ); 60 $u1 = self::factory()->user->create(); 61 61 $this->add_user_to_group( $u1, $g1 ); 62 62 … … 68 68 69 69 public function test_user_cannot_request_membership_in_public_group() { 70 $g1 = $this->factory->group->create( array(71 'status' => 'public' 72 ) ); 73 $u1 = $this->factory->user->create();70 $g1 = self::factory()->group->create( array( 71 'status' => 'public' 72 ) ); 73 $u1 = self::factory()->user->create(); 74 74 75 75 $this->assertFalse( bp_user_can( $u1, 'groups_request_membership', array( 'group_id' => $g1 ) ) ); … … 77 77 78 78 public function test_user_can_request_membership_in_private_group() { 79 $g1 = $this->factory->group->create( array(80 'status' => 'private' 81 ) ); 82 $u1 = $this->factory->user->create();79 $g1 = self::factory()->group->create( array( 80 'status' => 'private' 81 ) ); 82 $u1 = self::factory()->user->create(); 83 83 84 84 $this->assertTrue( bp_user_can( $u1, 'groups_request_membership', array( 'group_id' => $g1 ) ) ); … … 86 86 87 87 public function test_user_cannot_request_membership_in_hidden_group() { 88 $g1 = $this->factory->group->create( array(89 'status' => 'hidden' 90 ) ); 91 $u1 = $this->factory->user->create();88 $g1 = self::factory()->group->create( array( 89 'status' => 'hidden' 90 ) ); 91 $u1 = self::factory()->user->create(); 92 92 93 93 $this->assertFalse( bp_user_can( $u1, 'groups_request_membership', array( 'group_id' => $g1 ) ) ); … … 95 95 96 96 public function test_user_cannot_request_membership_in_private_group_if_already_member() { 97 $g1 = $this->factory->group->create( array(98 'status' => 'private' 99 ) ); 100 $u1 = $this->factory->user->create();97 $g1 = self::factory()->group->create( array( 98 'status' => 'private' 99 ) ); 100 $u1 = self::factory()->user->create(); 101 101 $this->add_user_to_group( $u1, $g1 ); 102 102 … … 105 105 106 106 public function test_user_cannot_request_membership_in_private_group_if_already_requested() { 107 $g1 = $this->factory->group->create( array(108 'status' => 'private' 109 ) ); 110 $u1 = $this->factory->user->create();107 $g1 = self::factory()->group->create( array( 108 'status' => 'private' 109 ) ); 110 $u1 = self::factory()->user->create(); 111 111 groups_send_membership_request( array( 112 112 'user_id' => $u1, … … 118 118 119 119 public function test_user_cannot_request_membership_in_private_group_if_banned() { 120 $g1 = $this->factory->group->create( array(121 'status' => 'private' 122 ) ); 123 $u1 = $this->factory->user->create();120 $g1 = self::factory()->group->create( array( 121 'status' => 'private' 122 ) ); 123 $u1 = self::factory()->user->create(); 124 124 $this->add_user_to_group( $u1, $g1 ); 125 125 … … 131 131 132 132 public function test_user_can_receive_invitation_to_private_group() { 133 $g1 = $this->factory->group->create( array(134 'status' => 'private' 135 ) ); 136 $u1 = $this->factory->user->create();133 $g1 = self::factory()->group->create( array( 134 'status' => 'private' 135 ) ); 136 $u1 = self::factory()->user->create(); 137 137 138 138 $this->assertTrue( bp_user_can( $u1, 'groups_receive_invitation', array( 'group_id' => $g1 ) ) ); … … 140 140 141 141 public function test_user_cannot_receive_invitation_to_private_group_if_already_member() { 142 $g1 = $this->factory->group->create( array(143 'status' => 'private' 144 ) ); 145 $u1 = $this->factory->user->create();142 $g1 = self::factory()->group->create( array( 143 'status' => 'private' 144 ) ); 145 $u1 = self::factory()->user->create(); 146 146 $this->add_user_to_group( $u1, $g1 ); 147 147 … … 157 157 } 158 158 159 $g1 = $this->factory->group->create( array(160 'status' => 'private' 161 ) ); 162 $u1 = $this->factory->user->create();159 $g1 = self::factory()->group->create( array( 160 'status' => 'private' 161 ) ); 162 $u1 = self::factory()->user->create(); 163 163 $this->add_user_to_group( $u1, $g1 ); 164 164 … … 170 170 171 171 public function test_user_cannot_receive_invitation_to_private_group_if_banned() { 172 $g1 = $this->factory->group->create( array(173 'status' => 'private' 174 ) ); 175 $u1 = $this->factory->user->create();172 $g1 = self::factory()->group->create( array( 173 'status' => 'private' 174 ) ); 175 $u1 = self::factory()->user->create(); 176 176 $this->add_user_to_group( $u1, $g1 ); 177 177 … … 183 183 184 184 public function test_user_can_receive_invitation_to_hidden_group() { 185 $g1 = $this->factory->group->create( array(186 'status' => 'hidden' 187 ) ); 188 $u1 = $this->factory->user->create();185 $g1 = self::factory()->group->create( array( 186 'status' => 'hidden' 187 ) ); 188 $u1 = self::factory()->user->create(); 189 189 190 190 $this->assertTrue( bp_user_can( $u1, 'groups_receive_invitation', array( 'group_id' => $g1 ) ) ); … … 192 192 193 193 public function test_user_cannot_send_invitation_to_public_group_if_not_a_member() { 194 $g1 = $this->factory->group->create( array(195 'status' => 'public' 196 ) ); 197 $u1 = $this->factory->user->create();194 $g1 = self::factory()->group->create( array( 195 'status' => 'public' 196 ) ); 197 $u1 = self::factory()->user->create(); 198 198 199 199 $this->assertFalse( bp_user_can( $u1, 'groups_send_invitation', array( 'group_id' => $g1 ) ) ); … … 201 201 202 202 public function test_user_cannot_send_invitation_to_private_group_if_not_a_member() { 203 $g1 = $this->factory->group->create( array(204 'status' => 'private' 205 ) ); 206 $u1 = $this->factory->user->create();203 $g1 = self::factory()->group->create( array( 204 'status' => 'private' 205 ) ); 206 $u1 = self::factory()->user->create(); 207 207 208 208 $this->assertFalse( bp_user_can( $u1, 'groups_send_invitation', array( 'group_id' => $g1 ) ) ); … … 210 210 211 211 public function test_user_cannot_send_invitation_to_private_group_if_banned() { 212 $g1 = $this->factory->group->create( array(212 $g1 = self::factory()->group->create( array( 213 213 'status' => 'private' 214 214 ) ); 215 215 groups_update_groupmeta( $g1, 'invite_status', 'members' ); 216 $u1 = $this->factory->user->create();216 $u1 = self::factory()->user->create(); 217 217 $this->add_user_to_group( $u1, $g1 ); 218 218 … … 224 224 225 225 public function test_user_can_send_invitation_to_private_group_if_a_member() { 226 $g1 = $this->factory->group->create( array(226 $g1 = self::factory()->group->create( array( 227 227 'status' => 'private', 228 228 229 229 ) ); 230 230 groups_update_groupmeta( $g1, 'invite_status', 'members' ); 231 $u1 = $this->factory->user->create();231 $u1 = self::factory()->user->create(); 232 232 $this->add_user_to_group( $u1, $g1 ); 233 233 … … 236 236 237 237 public function test_user_can_send_invitation_to_hidden_group_if_a_member() { 238 $g1 = $this->factory->group->create( array(239 'status' => 'hidden' 240 ) ); 241 $u1 = $this->factory->user->create();242 $u1 = $this->factory->user->create();238 $g1 = self::factory()->group->create( array( 239 'status' => 'hidden' 240 ) ); 241 $u1 = self::factory()->user->create(); 242 $u1 = self::factory()->user->create(); 243 243 $this->add_user_to_group( $u1, $g1 ); 244 244 … … 247 247 248 248 public function test_user_can_access_public_group_even_when_not_logged_in() { 249 $g1 = $this->factory->group->create( array(250 'status' => 'public' 251 ) ); 252 $old_user = get_current_user_id(); 253 $this->set_current_user( 0 );249 $g1 = self::factory()->group->create( array( 250 'status' => 'public' 251 ) ); 252 $old_user = get_current_user_id(); 253 self::set_current_user( 0 ); 254 254 255 255 $this->assertTrue( bp_user_can( 0, 'groups_access_group', array( 'group_id' => $g1 ) ) ); 256 256 257 $this->set_current_user( $old_user );257 self::set_current_user( $old_user ); 258 258 } 259 259 260 260 public function test_user_can_access_public_group_if_not_a_member() { 261 $g1 = $this->factory->group->create( array(262 'status' => 'public' 263 ) ); 264 $u1 = $this->factory->user->create();261 $g1 = self::factory()->group->create( array( 262 'status' => 'public' 263 ) ); 264 $u1 = self::factory()->user->create(); 265 265 266 266 $this->assertTrue( bp_user_can( $u1, 'groups_access_group', array( 'group_id' => $g1 ) ) ); … … 268 268 269 269 public function test_user_cannot_access_private_group_if_not_logged_in() { 270 $g1 = $this->factory->group->create( array(271 'status' => 'private' 272 ) ); 273 $old_user = get_current_user_id(); 274 $this->set_current_user( 0 );270 $g1 = self::factory()->group->create( array( 271 'status' => 'private' 272 ) ); 273 $old_user = get_current_user_id(); 274 self::set_current_user( 0 ); 275 275 276 276 $this->assertFalse( bp_user_can( 0, 'groups_access_group', array( 'group_id' => $g1 ) ) ); 277 277 278 $this->set_current_user( $old_user );278 self::set_current_user( $old_user ); 279 279 } 280 280 281 281 public function test_user_cannot_access_private_group_if_not_a_member() { 282 $g1 = $this->factory->group->create( array(283 'status' => 'private' 284 ) ); 285 $u1 = $this->factory->user->create();282 $g1 = self::factory()->group->create( array( 283 'status' => 'private' 284 ) ); 285 $u1 = self::factory()->user->create(); 286 286 287 287 $this->assertFalse( bp_user_can( $u1, 'groups_access_group', array( 'group_id' => $g1 ) ) ); … … 289 289 290 290 public function test_user_can_access_private_group_if_a_member() { 291 $g1 = $this->factory->group->create( array(292 'status' => 'private' 293 ) ); 294 $u1 = $this->factory->user->create();291 $g1 = self::factory()->group->create( array( 292 'status' => 'private' 293 ) ); 294 $u1 = self::factory()->user->create(); 295 295 $this->add_user_to_group( $u1, $g1 ); 296 296 … … 299 299 300 300 public function test_user_cannot_access_hidden_group_if_not_logged_in() { 301 $g1 = $this->factory->group->create( array(302 'status' => 'hidden' 303 ) ); 304 $old_user = get_current_user_id(); 305 $this->set_current_user( 0 );301 $g1 = self::factory()->group->create( array( 302 'status' => 'hidden' 303 ) ); 304 $old_user = get_current_user_id(); 305 self::set_current_user( 0 ); 306 306 307 307 $this->assertFalse( bp_user_can( 0, 'groups_access_group', array( 'group_id' => $g1 ) ) ); 308 308 309 $this->set_current_user( $old_user );309 self::set_current_user( $old_user ); 310 310 } 311 311 312 312 public function test_user_cannot_access_hidden_group_if_not_a_member() { 313 $g1 = $this->factory->group->create( array(314 'status' => 'hidden' 315 ) ); 316 $u1 = $this->factory->user->create();313 $g1 = self::factory()->group->create( array( 314 'status' => 'hidden' 315 ) ); 316 $u1 = self::factory()->user->create(); 317 317 318 318 $this->assertFalse( bp_user_can( $u1, 'groups_access_group', array( 'group_id' => $g1 ) ) ); … … 320 320 321 321 public function test_user_can_access_hidden_group_if_a_member() { 322 $g1 = $this->factory->group->create( array(323 'status' => 'hidden' 324 ) ); 325 $u1 = $this->factory->user->create();322 $g1 = self::factory()->group->create( array( 323 'status' => 'hidden' 324 ) ); 325 $u1 = self::factory()->user->create(); 326 326 $this->add_user_to_group( $u1, $g1 ); 327 327 … … 330 330 331 331 public function test_user_can_see_public_group_even_when_not_logged_in() { 332 $g1 = $this->factory->group->create( array(333 'status' => 'public' 334 ) ); 335 $old_user = get_current_user_id(); 336 $this->set_current_user( 0 );332 $g1 = self::factory()->group->create( array( 333 'status' => 'public' 334 ) ); 335 $old_user = get_current_user_id(); 336 self::set_current_user( 0 ); 337 337 338 338 $this->assertTrue( bp_user_can( 0, 'groups_see_group', array( 'group_id' => $g1 ) ) ); 339 339 340 $this->set_current_user( $old_user );340 self::set_current_user( $old_user ); 341 341 } 342 342 343 343 public function test_user_can_see_public_group() { 344 $g1 = $this->factory->group->create( array(345 'status' => 'public' 346 ) ); 347 $u1 = $this->factory->user->create();344 $g1 = self::factory()->group->create( array( 345 'status' => 'public' 346 ) ); 347 $u1 = self::factory()->user->create(); 348 348 349 349 $this->assertTrue( bp_user_can( $u1, 'groups_see_group', array( 'group_id' => $g1 ) ) ); … … 351 351 352 352 public function test_user_can_see_private_group_even_when_not_logged_in() { 353 $g1 = $this->factory->group->create( array(354 'status' => 'private' 355 ) ); 356 $old_user = get_current_user_id(); 357 $this->set_current_user( 0 );353 $g1 = self::factory()->group->create( array( 354 'status' => 'private' 355 ) ); 356 $old_user = get_current_user_id(); 357 self::set_current_user( 0 ); 358 358 359 359 $this->assertTrue( bp_user_can( 0, 'groups_see_group', array( 'group_id' => $g1 ) ) ); 360 360 361 $this->set_current_user( $old_user );361 self::set_current_user( $old_user ); 362 362 } 363 363 364 364 public function test_user_can_see_private_group() { 365 $g1 = $this->factory->group->create( array(366 'status' => 'private' 367 ) ); 368 $u1 = $this->factory->user->create();365 $g1 = self::factory()->group->create( array( 366 'status' => 'private' 367 ) ); 368 $u1 = self::factory()->user->create(); 369 369 370 370 $this->assertTrue( bp_user_can( $u1, 'groups_see_group', array( 'group_id' => $g1 ) ) ); … … 372 372 373 373 public function test_user_cannot_see_hidden_group_if_not_logged_in() { 374 $g1 = $this->factory->group->create( array(375 'status' => 'hidden' 376 ) ); 377 $old_user = get_current_user_id(); 378 $this->set_current_user( 0 );374 $g1 = self::factory()->group->create( array( 375 'status' => 'hidden' 376 ) ); 377 $old_user = get_current_user_id(); 378 self::set_current_user( 0 ); 379 379 380 380 $this->assertFalse( bp_user_can( 0, 'groups_see_group', array( 'group_id' => $g1 ) ) ); 381 381 382 $this->set_current_user( $old_user );382 self::set_current_user( $old_user ); 383 383 } 384 384 385 385 public function test_user_cannot_see_hidden_group_if_not_a_member() { 386 $g1 = $this->factory->group->create( array(387 'status' => 'hidden' 388 ) ); 389 $u1 = $this->factory->user->create();386 $g1 = self::factory()->group->create( array( 387 'status' => 'hidden' 388 ) ); 389 $u1 = self::factory()->user->create(); 390 390 391 391 $this->assertFalse( bp_user_can( $u1, 'groups_see_group', array( 'group_id' => $g1 ) ) ); … … 393 393 394 394 public function test_user_can_see_hidden_group_if_member() { 395 $g1 = $this->factory->group->create( array(396 'status' => 'hidden' 397 ) ); 398 $u1 = $this->factory->user->create();395 $g1 = self::factory()->group->create( array( 396 'status' => 'hidden' 397 ) ); 398 $u1 = self::factory()->user->create(); 399 399 $this->add_user_to_group( $u1, $g1 ); 400 400 … … 410 410 } 411 411 412 $g1 = $this->factory->group->create( array(412 $g1 = self::factory()->group->create( array( 413 413 'status' => 'public' 414 414 ) ); 415 $u1 = $this->factory->user->create();415 $u1 = self::factory()->user->create(); 416 416 $this->add_user_to_group( $u1, $g1 ); 417 417 -
trunk/tests/phpunit/testcases/members/activity.php
r13180 r13980 130 130 $prev_time = date( 'Y-m-d H:i:s', $time - ( 121 * HOUR_IN_SECONDS ) ); 131 131 132 $a =self::factory()->activity->create( array(132 self::factory()->activity->create( array( 133 133 'component' => buddypress()->members->id, 134 134 'type' => 'new_avatar', … … 161 161 $prev_time = date( 'Y-m-d H:i:s', $prev_timestamp ); 162 162 163 $a1 =self::factory()->activity->create( array(163 self::factory()->activity->create( array( 164 164 'component' => buddypress()->members->id, 165 165 'type' => 'new_avatar', … … 168 168 ) ); 169 169 170 $a2 =self::factory()->activity->create(170 self::factory()->activity->create( 171 171 array( 172 172 'component' => buddypress()->members->id, -
trunk/tests/phpunit/testcases/members/class-bp-signup.php
r13314 r13980 10 10 11 11 public function set_up() { 12 13 12 if ( is_multisite() ) { 14 13 $this->signup_allowed = get_site_option( 'registration' ); -
trunk/tests/phpunit/testcases/members/functions.php
r13894 r13980 33 33 34 34 // 1. Admin can delete user account 35 $this->set_current_user( $admin_user );35 self::set_current_user( $admin_user ); 36 36 $user1 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 37 37 bp_core_delete_account( $user1 ); … … 52 52 $user3 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 53 53 $user4 = self::factory()->user->create( array( 'role' => 'subscriber' ) ); 54 $this->set_current_user( $user3 );54 self::set_current_user( $user3 ); 55 55 bp_core_delete_account( $user4 ); 56 56 $maybe_user = new WP_User( $user4 ); … … 59 59 60 60 // Cleanup 61 $this->set_current_user( $current_user );61 self::set_current_user( $current_user ); 62 62 bp_update_option( 'bp-disable-account-deletion', $deletion_disabled ); 63 63 } … … 747 747 748 748 // Create the signup. 749 $this->factory->signup->create( array(749 self::factory()->signup->create( array( 750 750 'user_login' => 'test', 751 751 'user_email' => 'test@example.com', -
trunk/tests/phpunit/testcases/members/template.php
r13433 r13980 72 72 73 73 $old_user = get_current_user_id(); 74 $this->set_current_user( $u2 );74 self::set_current_user( $u2 ); 75 75 $this->set_permalink_structure( '/%postname%/' ); 76 76 … … 95 95 $this->assertEquals( $request_ids, array( $u1 ) ); 96 96 97 $this->set_current_user( $old_user );97 self::set_current_user( $old_user ); 98 98 } 99 99 … … 108 108 109 109 $old_user = get_current_user_id(); 110 $this->set_current_user( $u2 );110 self::set_current_user( $u2 ); 111 111 $this->set_permalink_structure( '/%postname%/' ); 112 112 … … 137 137 $this->assertEquals( array(), $request_ids ); 138 138 139 $this->set_current_user( $old_user );139 self::set_current_user( $old_user ); 140 140 } 141 141 -
trunk/tests/phpunit/testcases/members/template/bpGetMemberTypeDirectoryPermalink.php
r13436 r13980 16 16 17 17 public function tear_down() { 18 $this->set_permalink_structure( $this->permalink_structure ); 19 18 20 parent::tear_down(); 19 20 $this->set_permalink_structure( $this->permalink_structure );21 21 } 22 22 -
trunk/tests/phpunit/testcases/messages/cache.php
r13414 r13980 145 145 // delete thread 146 146 // to outright delete a thread, both recipients must delete it 147 $this->set_current_user( $u1 );147 self::set_current_user( $u1 ); 148 148 messages_delete_thread( $t1 ); 149 $this->set_current_user( $u2 );149 self::set_current_user( $u2 ); 150 150 messages_delete_thread( $t1 ); 151 151 … … 155 155 156 156 // cleanup 157 $this->set_current_user( $this->old_current_user );157 self::set_current_user( $this->old_current_user ); 158 158 } 159 159 -
trunk/tests/phpunit/testcases/messages/class.bp-messages-notice.php
r13314 r13980 10 10 public function set_up() { 11 11 parent::set_up(); 12 12 13 $this->old_current_user = get_current_user_id(); 13 $this->set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );14 self::set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 14 15 } 15 16 16 17 public function tear_down() { 18 self::set_current_user( $this->old_current_user ); 19 17 20 parent::tear_down(); 18 $this->set_current_user( $this->old_current_user );19 21 } 20 22 … … 50 52 $this->assertEquals( $message2, $cache->message ); 51 53 } 52 53 54 } -
trunk/tests/phpunit/testcases/messages/class.bp-messages-thread.php
r13859 r13980 572 572 // Mark thread as read 573 573 $current_user = get_current_user_id(); 574 $this->set_current_user( $u2 );574 self::set_current_user( $u2 ); 575 575 messages_mark_thread_read( $t1 ); 576 576 … … 578 578 $this->assertFalse( wp_cache_get( 'thread_recipients_' . $t1, 'bp_messages' ) ); 579 579 580 $this->set_current_user( $current_user );580 self::set_current_user( $current_user ); 581 581 } 582 582 … … 674 674 // Mark thread as unread 675 675 $current_user = get_current_user_id(); 676 $this->set_current_user( $u2 );676 self::set_current_user( $u2 ); 677 677 messages_mark_thread_unread( $t1 ); 678 678 … … 680 680 $this->assertFalse( wp_cache_get( 'thread_recipients_' . $t1, 'bp_messages' ) ); 681 681 682 $this->set_current_user( $current_user );682 self::set_current_user( $current_user ); 683 683 } 684 684 -
trunk/tests/phpunit/testcases/messages/functions.php
r12403 r13980 23 23 24 24 // get unread count for $u2 25 $this->set_current_user( $u2 );25 self::set_current_user( $u2 ); 26 26 $this->assertEquals( 1, messages_get_unread_count( $u2 ) ); 27 27 -
trunk/tests/phpunit/testcases/messages/notifications.php
r13414 r13980 8 8 class BP_Tests_Messages_Notifications extends BP_UnitTestCase { 9 9 10 protected $reset_user_id = 0; 10 11 protected $filter_fired; 11 12 … … 14 15 15 16 $this->reset_user_id = get_current_user_id(); 16 17 17 $this->filter_fired = ''; 18 18 } 19 19 20 20 public function tear_down() { 21 self::set_current_user( $this->reset_user_id ); 22 21 23 parent::tear_down(); 22 23 $this->set_current_user( $this->reset_user_id );24 24 } 25 25 … … 31 31 $t = 12; 32 32 $u = self::factory()->user->create(); 33 $this->set_current_user( $u );33 self::set_current_user( $u ); 34 34 35 35 // Admin … … 55 55 $t = 12; 56 56 $u = self::factory()->user->create(); 57 $this->set_current_user( $u );57 self::set_current_user( $u ); 58 58 59 59 // Admin … … 79 79 $t = 12; 80 80 $u = self::factory()->user->create(); 81 $this->set_current_user( $u );81 self::set_current_user( $u ); 82 82 83 83 // Admin … … 103 103 $t = 12; 104 104 $u = self::factory()->user->create(); 105 $this->set_current_user( $u );105 self::set_current_user( $u ); 106 106 107 107 // Admin … … 189 189 ); 190 190 191 $this->set_current_user( $u1 );191 self::set_current_user( $u1 ); 192 192 193 193 // Mark a thread read. -
trunk/tests/phpunit/testcases/messages/star.php
r11737 r13980 155 155 156 156 // delete the second thread 157 $this->set_current_user( $u2 );157 self::set_current_user( $u2 ); 158 158 messages_delete_thread( $t2 ); 159 159 … … 169 169 170 170 // reset 171 $this->set_current_user( $old_current_user );171 self::set_current_user( $old_current_user ); 172 172 } 173 173 -
trunk/tests/phpunit/testcases/messages/template.php
r13339 r13980 281 281 // set user to anonymous 282 282 $old_current_user = get_current_user_id(); 283 $this->set_current_user( 0 );283 self::set_current_user( 0 ); 284 284 285 285 // now, do the message thread query … … 291 291 $this->assertEmpty( $messages_template->threads ); 292 292 293 $this->set_current_user( $old_current_user );293 self::set_current_user( $old_current_user ); 294 294 } 295 295 … … 462 462 // set $u1 as current user. 463 463 $old_current_user = get_current_user_id(); 464 $this->set_current_user( $u1 );464 self::set_current_user( $u1 ); 465 465 466 466 $messages_template = new BP_Messages_Box_Template( … … 471 471 ); 472 472 473 $this->set_current_user( $old_current_user );473 self::set_current_user( $old_current_user ); 474 474 475 475 $thread = reset( $messages_template->threads ); -
trunk/tests/phpunit/testcases/routing/activity.php
r13433 r13980 13 13 $this->old_current_user = get_current_user_id(); 14 14 $this->permalink_structure = get_option( 'permalink_structure', '' ); 15 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );15 self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 16 16 } 17 17 18 18 public function tear_down() { 19 self::set_current_user( $this->old_current_user ); 20 $this->set_permalink_structure( $this->permalink_structure ); 21 19 22 parent::tear_down(); 20 $this->set_current_user( $this->old_current_user );21 $this->set_permalink_structure( $this->permalink_structure );22 23 } 23 24 -
trunk/tests/phpunit/testcases/routing/core.php
r13507 r13980 12 12 13 13 $this->old_current_user = get_current_user_id(); 14 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );14 self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 15 15 $this->permalink_structure = get_option( 'permalink_structure', '' ); 16 16 } 17 17 18 18 public function tear_down() { 19 self::set_current_user( $this->old_current_user ); 20 $this->set_permalink_structure( $this->permalink_structure ); 21 19 22 parent::tear_down(); 20 $this->set_current_user( $this->old_current_user );21 $this->set_permalink_structure( $this->permalink_structure );22 23 } 23 24 -
trunk/tests/phpunit/testcases/routing/friends.php
r13433 r13980 13 13 $this->old_current_user = get_current_user_id(); 14 14 $this->permalink_structure = get_option( 'permalink_structure', '' ); 15 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );15 self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 16 16 } 17 17 18 18 public function tear_down() { 19 self::set_current_user( $this->old_current_user ); 20 $this->set_permalink_structure( $this->permalink_structure ); 21 19 22 parent::tear_down(); 20 $this->set_current_user( $this->old_current_user );21 $this->set_permalink_structure( $this->permalink_structure );22 23 } 23 24 -
trunk/tests/phpunit/testcases/routing/groups.php
r13468 r13980 14 14 $this->old_current_user = get_current_user_id(); 15 15 $this->permalink_structure = get_option( 'permalink_structure', '' ); 16 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );16 self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 17 17 } 18 18 19 19 public function tear_down() { 20 self::set_current_user( $this->old_current_user ); 21 $this->set_permalink_structure( $this->permalink_structure ); 22 20 23 parent::tear_down(); 21 $this->set_current_user( $this->old_current_user );22 $this->set_permalink_structure( $this->permalink_structure );23 24 } 24 25 … … 219 220 $this->assertEquals( $g2, bp_get_current_group_id() ); 220 221 } 221 222 222 } -
trunk/tests/phpunit/testcases/routing/members.php
r13720 r13980 14 14 $this->old_current_user = get_current_user_id(); 15 15 $this->permalink_structure = get_option( 'permalink_structure', '' ); 16 $this->set_current_user( self::factory()->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );16 self::set_current_user( self::factory()->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) ); 17 17 } 18 18 19 19 public function tear_down() { 20 $this->set_current_user( $this->old_current_user );20 self::set_current_user( $this->old_current_user ); 21 21 $this->set_permalink_structure( $this->permalink_structure ); 22 22 23 parent::tear_down(); 23 24 } -
trunk/tests/phpunit/testcases/routing/messages.php
r13433 r13980 13 13 $this->old_current_user = get_current_user_id(); 14 14 $this->permalink_structure = get_option( 'permalink_structure', '' ); 15 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );15 self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 16 16 } 17 17 18 18 public function tear_down() { 19 self::set_current_user( $this->old_current_user ); 20 $this->set_permalink_structure( $this->permalink_structure ); 21 19 22 parent::tear_down(); 20 $this->set_current_user( $this->old_current_user );21 $this->set_permalink_structure( $this->permalink_structure );22 23 } 23 24 -
trunk/tests/phpunit/testcases/routing/root-profiles.php
r13468 r13980 21 21 ) ); 22 22 $this->u = new WP_User( $uid ); 23 $this->set_current_user( $uid );23 self::set_current_user( $uid ); 24 24 $this->permalink_structure = get_option( 'permalink_structure', '' ); 25 25 } 26 26 27 27 public function tear_down() { 28 parent::tear_down(); 29 $this->set_current_user( $this->old_current_user ); 28 self::set_current_user( $this->old_current_user ); 30 29 $this->set_permalink_structure( $this->permalink_structure ); 31 30 remove_filter( 'bp_core_enable_root_profiles', '__return_true' ); 31 32 parent::tear_down(); 32 33 } 33 34 -
trunk/tests/phpunit/testcases/routing/settings.php
r13433 r13980 13 13 $this->old_current_user = get_current_user_id(); 14 14 $this->permalink_structure = get_option( 'permalink_structure', '' ); 15 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );15 self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 16 16 } 17 17 18 18 public function tear_down() { 19 self::set_current_user( $this->old_current_user ); 20 $this->set_permalink_structure( $this->permalink_structure ); 21 19 22 parent::tear_down(); 20 $this->set_current_user( $this->old_current_user );21 $this->set_permalink_structure( $this->permalink_structure );22 23 } 23 24 -
trunk/tests/phpunit/testcases/routing/xprofile.php
r13433 r13980 13 13 $this->old_current_user = get_current_user_id(); 14 14 $this->permalink_structure = get_option( 'permalink_structure', '' ); 15 $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );15 self::set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) ); 16 16 } 17 17 18 18 public function tear_down() { 19 self::set_current_user( $this->old_current_user ); 20 $this->set_permalink_structure( $this->permalink_structure ); 21 19 22 parent::tear_down(); 20 $this->set_current_user( $this->old_current_user );21 $this->set_permalink_structure( $this->permalink_structure );22 23 } 23 24 -
trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field-type.php
r13314 r13980 16 16 17 17 public function tear_down() { 18 remove_filter( 'bp_xprofile_get_field_types', array( $this, 'get_field_types' ) ); 19 18 20 parent::tear_down(); 19 20 remove_filter( 'bp_xprofile_get_field_types', array( $this, 'get_field_types' ) );21 21 } 22 22 -
trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field.php
r11847 r13980 218 218 219 219 $old_user = get_current_user_id(); 220 $this->set_current_user( $user );220 self::set_current_user( $user ); 221 221 222 222 $value = bp_get_profile_field_data( array( 'user_id' => $user, 'field' => $field ) ); 223 223 $this->assertEmpty( $value ); 224 224 225 $this->set_current_user( $old_user );225 self::set_current_user( $old_user ); 226 226 } 227 227 -
trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-query.php
r13314 r13980 9 9 protected $fields = array(); 10 10 protected $users = array(); 11 12 public function tear_down() {13 parent::tear_down();14 $this->group = '';15 $this->fields = array();16 $this->users = array();17 }18 11 19 12 public function test_no_field() { -
trunk/tests/phpunit/testcases/xprofile/functions.php
r13792 r13980 10 10 11 11 $old_current_user = bp_loggedin_user_id(); 12 $this->set_current_user( 0 );12 self::set_current_user( 0 ); 13 13 14 14 $this->assertEquals( array( 'friends', 'loggedin', 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) ); 15 15 16 $this->set_current_user( $old_current_user );16 self::set_current_user( $old_current_user ); 17 17 } 18 18 … … 22 22 23 23 $old_current_user = bp_loggedin_user_id(); 24 $this->set_current_user( $cuser );24 self::set_current_user( $cuser ); 25 25 26 26 $this->assertEquals( array( 'friends', 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) ); 27 27 28 $this->set_current_user( $old_current_user );28 self::set_current_user( $old_current_user ); 29 29 } 30 30 … … 35 35 36 36 $old_current_user = bp_loggedin_user_id(); 37 $this->set_current_user( $cuser );37 self::set_current_user( $cuser ); 38 38 39 39 $this->assertEquals( array( 'adminsonly' ), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) ); 40 40 41 $this->set_current_user( $old_current_user );41 self::set_current_user( $old_current_user ); 42 42 } 43 43 … … 48 48 49 49 $old_current_user = bp_loggedin_user_id(); 50 $this->set_current_user( $cuser );50 self::set_current_user( $cuser ); 51 51 52 52 $this->assertEquals( array(), bp_xprofile_get_hidden_field_types_for_user( $duser, bp_loggedin_user_id() ) ); 53 53 54 54 $this->revoke_bp_moderate( $cuser ); 55 $this->set_current_user( $old_current_user );55 self::set_current_user( $old_current_user ); 56 56 } 57 57 -
trunk/tests/phpunit/testcases/xprofile/template.php
r13797 r13980 19 19 ); 20 20 21 $this->set_current_user( $u1 );21 self::set_current_user( $u1 ); 22 22 23 23 bp_has_profile( … … 32 32 $this->assertEquals( 'Foo Bar', $field->data->value, 'The primary field should be the Name one and its value should be the same than the display name, by default' ); 33 33 34 $this->set_current_user( $prev_user );34 self::set_current_user( $prev_user ); 35 35 $profile_template = $reset_profile_template; 36 36 }
Note: See TracChangeset
for help on using the changeset viewer.