コード例 #1
0
 /**
  * @group bp_blogs_remove_blog
  */
 public function test_bp_blogs_remove_blog()
 {
     if (!is_multisite()) {
         return;
     }
     $reset_post = $_POST;
     $old_user = get_current_user_id();
     // Simulate a new "BuddyPress generated" blog
     $_POST['blog_public'] = 1;
     $u = $this->factory->user->create();
     $this->set_current_user($u);
     // Create three sites.
     $b = $this->factory->blog->create(array('user_id' => $u));
     $activity = bp_activity_get(array('filter' => array('object' => 'blogs', 'action' => 'new_blog', 'primary_id' => $b)));
     $new_blog = array_map('intval', wp_list_pluck($activity['activities'], 'item_id', 'id'));
     $this->assertSame($b, reset($new_blog));
     // Removing the blog should delete the activity and the blog association.
     wpmu_delete_blog($b);
     $deleted = bp_activity_get(array('in' => array_keys($new_blog)));
     $this->assertEmpty($deleted['activities']);
     $this->assertEmpty(BP_Blogs_Blog::is_recorded($b));
     $_POST = $reset_post;
     $this->set_current_user($old_user);
 }