Changeset 25391
- Timestamp:
- 09/12/2013 06:06:07 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user/capabilities.php
r25353 r25391 16 16 17 17 $this->orig_users = get_users(); 18 add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); 19 } 20 21 function tearDown() { 22 parent::tearDown(); 23 remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); 24 } 25 26 function deprecated_function_run( $function ) { 27 if ( in_array( $function, array( 'set_current_user' ) ) ) 28 add_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) ); 29 } 30 31 function deprecated_function_trigger_error() { 32 remove_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) ); 33 return false; 18 34 } 19 35 … … 668 684 set_current_user( $old_uid ); 669 685 } 686 687 function test_wp_set_current_user() { 688 $user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); 689 $old_uid = get_current_user_id(); 690 wp_set_current_user( $user->ID ); 691 692 $this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) ); 693 $this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'foo_the_bar' ) ); 694 if ( ! is_multisite() ) { 695 $this->assertTrue( current_user_can_for_blog( 12345, 'edit_posts' ) ); 696 return; 697 } 698 699 $this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) ); 700 701 $blog_id = $this->factory->blog->create( array( 'user_id' => $user->ID ) ); 702 $this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) ); 703 $this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) ); 704 705 wp_set_current_user( $old_uid ); 706 } 670 707 }
Note: See TracChangeset
for help on using the changeset viewer.