Changeset 10971 for trunk/tests/phpunit/testcases/blogs/functions.php
- Timestamp:
- 07/30/2016 11:40:55 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/blogs/functions.php
r10815 r10971 1017 1017 } 1018 1018 1019 /** 1020 * @group bp_blogs_remove_blog 1021 */ 1022 public function test_bp_blogs_remove_blog() { 1023 if ( ! is_multisite() ) { 1024 return; 1025 } 1026 1027 $reset_post = $_POST; 1028 $old_user = get_current_user_id(); 1029 1030 // Simulate a new "BuddyPress generated" blog 1031 $_POST['blog_public'] = 1; 1032 1033 $u = $this->factory->user->create(); 1034 $this->set_current_user( $u ); 1035 1036 // Create three sites. 1037 $b = $this->factory->blog->create( array( 1038 'user_id' => $u 1039 ) ); 1040 1041 $activity = bp_activity_get( array( 1042 'filter' => array( 1043 'object' => 'blogs', 1044 'action' => 'new_blog', 1045 'primary_id' => $b, 1046 ), 1047 ) ); 1048 1049 $new_blog = array_map( 'intval', wp_list_pluck( $activity['activities'], 'item_id', 'id' ) ); 1050 $this->assertSame( $b, reset( $new_blog ) ); 1051 1052 // Removing the blog should delete the activity and the blog association. 1053 wpmu_delete_blog( $b ); 1054 1055 $deleted = bp_activity_get( array( 1056 'in' => array_keys( $new_blog ), 1057 ) ); 1058 1059 $this->assertEmpty( $deleted['activities'] ); 1060 $this->assertEmpty( BP_Blogs_Blog::is_recorded( $b ) ); 1061 1062 $_POST = $reset_post; 1063 $this->set_current_user( $old_user ); 1064 } 1065 1066 /** 1067 * @group bp_blogs_remove_blog_for_user 1068 */ 1069 public function test_bp_blogs_remove_blog_for_user_is_contributor() { 1070 if ( ! is_multisite() ) { 1071 return; 1072 } 1073 1074 $reset_post = $_POST; 1075 $old_user = get_current_user_id(); 1076 1077 // Simulate a new "BuddyPress generated" blog 1078 $_POST['blog_public'] = 1; 1079 1080 $u = $this->factory->user->create(); 1081 $this->set_current_user( $u ); 1082 1083 // Create three sites. 1084 $b = $this->factory->blog->create( array( 1085 'user_id' => $u 1086 ) ); 1087 1088 $u2 = $this->factory->user->create(); 1089 add_user_to_blog( $b, $u2, 'contributor' ); 1090 1091 $u2_blogs = BP_Blogs_Blog::get_blog_ids_for_user( $u2 ); 1092 $this->assertContains( $b, $u2_blogs, 'The user should be associated to the blog as he is a contributor' ); 1093 1094 remove_user_from_blog( $u2, $b ); 1095 $u2_blogs = BP_Blogs_Blog::get_blog_ids_for_user( $u2 ); 1096 $this->assertNotContains( $b, $u2_blogs, 'The user should not be associated anymore to the blog' ); 1097 1098 $activity = bp_activity_get( array( 1099 'filter' => array( 1100 'object' => 'blogs', 1101 'action' => 'new_blog', 1102 'primary_id' => $b, 1103 ), 1104 ) ); 1105 1106 $new_blog = array_map( 'intval', wp_list_pluck( $activity['activities'], 'item_id', 'id' ) ); 1107 $this->assertSame( $b, reset( $new_blog ), 'The new_blog activity should not be deleted when a contributor is removed from the blog.' ); 1108 1109 $_POST = $reset_post; 1110 $this->set_current_user( $old_user ); 1111 } 1112 1019 1113 protected function activity_exists_for_post( $post_id ) { 1020 1114 $a = bp_activity_get( array(
Note: See TracChangeset
for help on using the changeset viewer.