[buddypress-trac] [BuddyPress Trac] #6540: Multisite unit tests and bp_blogs_record_existing_blogs()

buddypress-trac noreply at wordpress.org
Mon Jun 29 15:55:39 UTC 2015

#6540: Multisite unit tests and bp_blogs_record_existing_blogs()
 Reporter:  imath                  |       Owner:
     Type:  defect (bug)           |      Status:  new
 Priority:  normal                 |   Milestone:  2.4
Component:  Tools - Unit Tests     |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |

Comment (by boonebgorges):

 Thanks for the digging, imath.

 The root of the problem is this. Test fixtures, such as users, are created
 inside of a MySQL transaction. The WP test suite sets `AUTOCOMMIT=0`,
 which means that all writes are logged and then rolled back during
 `tearDown()` (`'ROLLBACK;'`). However, `bp_blogs_record_existing_blogs()`
 calls `TRUNCATE`, and `TRUNCATE` causes an implicit commit. As a result,
 any fixtures created before `bp_blogs_record_existing_blogs()` are
 committed to the database and not rolled back during `tearDown()`.

 There are a couple possible solutions.

 1. Use `DELETE` instead of `TRUNCATE` in
 `bp_blogs_record_existing_blogs()`. This is, in fact, the way the function
 worked until [8585]. The commit message says that the purpose was to reset
 the auto-increment value. This reset does seem like a good thing, all
 things being equal, but it would be nice if johnjamesjacoby could chime in
 with more context.

 2. Do a manual teardown of users, etc after every test. This is pretty
 much what we're already doing, and it's what imath's 6540.patch suggests.

 3. Refactor existing tests that call `bp_blogs_record_existing_blogs()` so
 that they clean up after themselves.

 Option 3 seems a lot more precise to me than 2. I'm going to work on a

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6540#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list