| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @group update |
| 5 | */ |
| 6 | class BP_Tests_Update extends BP_UnitTestCase { |
| 7 | /** |
| 8 | * @group bp_update_to_2_0 |
| 9 | */ |
| 10 | public function test_upgrade_to_2_0_user_with_user_status_0_and_activation_key() { |
| 11 | if ( is_multisite() ) { |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | if ( ! function_exists( 'bp_core_install_activity_streams' ) ) { |
| 16 | require_once( buddypress()->plugin_dir . 'bp-core/admin/bp-core-schema.php' ); |
| 17 | } |
| 18 | |
| 19 | $u = $this->create_user(); |
| 20 | $user = new WP_User( $u ); |
| 21 | $user->add_role( 'editor' ); |
| 22 | |
| 23 | update_user_meta( $u, 'activation_key', 'foo' ); |
| 24 | |
| 25 | bp_update_to_2_0(); |
| 26 | |
| 27 | $u2 = new WP_User( $u ); |
| 28 | |
| 29 | $this->assertTrue( in_array( 'editor', $u2->roles ) ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @group bp_update_to_2_0 |
| 34 | */ |
| 35 | public function test_upgrade_to_2_0_user_with_user_status_2_and_activation_key() { |
| 36 | if ( is_multisite() ) { |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | if ( ! function_exists( 'bp_core_install_activity_streams' ) ) { |
| 41 | require_once( buddypress()->plugin_dir . 'bp-core/admin/bp-core-schema.php' ); |
| 42 | } |
| 43 | |
| 44 | global $wpdb; |
| 45 | |
| 46 | $u = $this->create_user(); |
| 47 | $wpdb->update( $wpdb->users, array( 'user_status' => '2' ), array( 'ID' => $u ) ); |
| 48 | clean_user_cache( $u ); |
| 49 | |
| 50 | $user = new WP_User( $u ); |
| 51 | $user->add_role( 'editor' ); |
| 52 | |
| 53 | update_user_meta( $u, 'activation_key', 'foo' ); |
| 54 | |
| 55 | bp_update_to_2_0(); |
| 56 | |
| 57 | $u2 = new WP_User( $u ); |
| 58 | |
| 59 | $this->assertTrue( ! in_array( 'editor', $u2->roles ) ); |
| 60 | } |
| 61 | } |