Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#29996 closed enhancement (fixed)

Improve tests for get_blogs_of_user()

Reported by: jeremyfelt's profile jeremyfelt Owned by: jeremyfelt's profile jeremyfelt
Milestone: 4.1 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: multisite Cc:


Our current multisite test for get_blogs_of_user() creates a user and 10 new sites, removes the user from the primary site on the network, and then tests to see if the user is still a member of those 10 sites. It also duplicates some of the efforts of our single site test, which handles the multisite case for a deleted user.

We can expand coverage a bit in get_blogs_of_user() and gain some speed / reduce duplicity.

Attachments (2)

29996.diff (3.1 KB) - added by jeremyfelt 9 years ago.
29996.2.diff (4.0 KB) - added by jeremyfelt 9 years ago.

Download all attachments as: .zip

Change History (5)

9 years ago

#1 @jeremyfelt
9 years ago

In 29996.diff, we:

  • Create 8 new sites rather than 10. This is pretty arbitrary, as we don't need all of them. It is nice to know that things work though.
  • Remove the user from multiple sites rather than only the first. This reduces the number of overall assertions that we make and helps to ensure that get_blogs_of_user() continues to provide accurate data.
  • Remove duplicate assertions for logged out users and deleted users, these are available in the single site test for get_blogs_of_user(). The one piece missing from the single site version is moved over.

And... accidentally leave bad docs for the test method. :) Do we have doc standards for tests yet?

9 years ago

#2 @jeremyfelt
9 years ago

  • Keywords has-patch added

29996.2.diff adds more assertions to test the second parameter of get_blogs_of_user() by marking sites as spam, archived, and deleted.

#3 @jeremyfelt
9 years ago

  • Owner set to jeremyfelt
  • Resolution set to fixed
  • Status changed from new to closed

In 29937:

Improve and reduce tests for get_blogs_of_user()

  • Create half as many factory sites. See #30017
  • Test the removal of a user from multiple sites.
  • Expand tests to include second parameter for flagged sites.
  • Remove duplicate test for deleted user.

Fixes #29996

Note: See TracTickets for help on using tickets.