Skip to content

Instantly share code, notes, and snippets.

@paulgibbs
Created December 24, 2014 16:30
Show Gist options
  • Save paulgibbs/26e86d6aa88f8c5dfc8d to your computer and use it in GitHub Desktop.
Save paulgibbs/26e86d6aa88f8c5dfc8d to your computer and use it in GitHub Desktop.
diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php
index 97e650b..ebe9038 100644
--- a/tests/phpunit/includes/testcase.php
+++ b/tests/phpunit/includes/testcase.php
@@ -54,6 +54,24 @@ class BP_UnitTestCase extends WP_UnitTestCase {
parent::clean_up_global_scope();
}
+ function tearDown() {
+ parent::tearDown();
+
+ /**
+ * Sites created by the WP_UnitTest_Factory_For_Blog sometimes are not removed when the current
+ * transaction is rolled back. This requires further investigation to understand the root cause
+ * but for now, we'll empty out the blogs table manually.
+ */
+ global $wpdb;
+
+ $blogs = wp_get_sites();
+ foreach ( $blogs as $blog ) {
+ if ( (int) $blog['blog_id'] !== 1 ) {
+ wpmu_delete_blog( $blog['blog_id'], true );
+ }
+ }
+ }
+
function assertPreConditions() {
parent::assertPreConditions();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment