Index: tests/phpunit/includes/bootstrap.php
===================================================================
--- tests/phpunit/includes/bootstrap.php	(revision 30242)
+++ tests/phpunit/includes/bootstrap.php	(working copy)
@@ -132,6 +132,7 @@
 			switch ( $option[0] ) {
 				case '--exclude-group' :
 					$ajax_message = false;
+					$ms_files_message = false;
 					continue 2;
 				case '--group' :
 					$groups = explode( ',', $option[1] );
@@ -141,12 +142,16 @@
 						}
 					}
 					$ajax_message = ! in_array( 'ajax', $groups );
+					$ms_files_message = ! in_array( 'ms-files', $groups );
 					continue 2;
 			}
 		}
 		if ( $ajax_message ) {
 			echo "Not running ajax tests... To execute these, use --group ajax." . PHP_EOL;
 		}
+		if ( $ms_files_message ) {
+			echo "Not running ms_files_rewriting tests... To execute these, use --group ms-files." . PHP_EOL;
+		}
     }
 }
 new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] );
Index: tests/phpunit/multisite.xml
===================================================================
--- tests/phpunit/multisite.xml	(revision 30242)
+++ tests/phpunit/multisite.xml	(working copy)
@@ -23,6 +23,7 @@
     <groups>
         <exclude>
             <group>ajax</group>
+            <group>ms-files</group>
         </exclude>
     </groups>
     <php>
Index: tests/phpunit/tests/multisite/ms-files-rewriting.php
===================================================================
--- tests/phpunit/tests/multisite/ms-files-rewriting.php	(revision 0)
+++ tests/phpunit/tests/multisite/ms-files-rewriting.php	(working copy)
@@ -0,0 +1,59 @@
+<?php
+
+if ( is_multisite() ) :
+
+/**
+ * Tests specific to the ms_files_rewriting option in multisite.
+ *
+ * The ms-files group tag must be used for these tests to run as the constants
+ * set in ms_upload_constants() conflict with a non ms-files configuration.
+ *
+ * @group ms-files
+ * @group multisite
+ */
+class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase {
+	protected $suppress = false;
+
+	function setUp() {
+		global $wpdb;
+		parent::setUp();
+		$this->suppress = $wpdb->suppress_errors();
+
+		$_SERVER[ 'REMOTE_ADDR' ] = '';
+
+		update_site_option( 'ms_files_rewriting', 1 );
+		ms_upload_constants();
+	}
+
+	function tearDown() {
+		global $wpdb;
+		update_site_option( 'ms_files_rewriting', 0 );
+		parent::tearDown();
+		$wpdb->suppress_errors( $this->suppress );
+	}
+
+	function test_switch_upload_dir() {
+		$this->assertTrue( is_main_site() );
+
+		$site = get_current_site();
+
+		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
+		$blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) );
+		$info = wp_upload_dir();
+		$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
+		$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
+		$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
+		$this->assertEquals( '', $info['error'] );
+
+		switch_to_blog( $blog_id2 );
+		$info2 = wp_upload_dir();
+		$this->assertNotEquals( $info, $info2 );
+		$this->assertEquals( get_option( 'siteurl' )  . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['url'] );
+		$this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['path'] );
+		$this->assertEquals( gmstrftime('/%Y/%m'), $info2['subdir'] );
+		$this->assertEquals( '', $info2['error'] );
+		restore_current_blog();
+	}
+}
+
+endif;
\ No newline at end of file
Index: tests/phpunit/tests/multisite/site.php
===================================================================
--- tests/phpunit/tests/multisite/site.php	(revision 30242)
+++ tests/phpunit/tests/multisite/site.php	(working copy)
@@ -949,27 +949,6 @@
 		$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
 		$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
 		$this->assertEquals( '', $info['error'] );
-
-		update_site_option( 'ms_files_rewriting', 1 );
-		ms_upload_constants();
-
-		$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
-		$blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) );
-		$info = wp_upload_dir();
-		$this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );
-		$this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );
-		$this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );
-		$this->assertEquals( '', $info['error'] );
-
-		switch_to_blog( $blog_id2 );
-		$info2 = wp_upload_dir();
-		$this->assertNotEquals( $info, $info2 );
-		$this->assertEquals( get_option( 'siteurl' )  . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['url'] );
-		$this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['path'] );
-		$this->assertEquals( gmstrftime('/%Y/%m'), $info2['subdir'] );
-		$this->assertEquals( '', $info2['error'] );
-		restore_current_blog();
-		update_site_option( 'ms_files_rewriting', 0 );
 	}
 
 	/**
