Ticket #30256: 30256.diff
File 30256.diff, 5.1 KB (added by , 11 years ago) |
---|
-
tests/phpunit/includes/bootstrap.php
132 132 switch ( $option[0] ) { 133 133 case '--exclude-group' : 134 134 $ajax_message = false; 135 $ms_files_message = false; 135 136 continue 2; 136 137 case '--group' : 137 138 $groups = explode( ',', $option[1] ); … … 141 142 } 142 143 } 143 144 $ajax_message = ! in_array( 'ajax', $groups ); 145 $ms_files_message = ! in_array( 'ms-files', $groups ); 144 146 continue 2; 145 147 } 146 148 } 147 149 if ( $ajax_message ) { 148 150 echo "Not running ajax tests... To execute these, use --group ajax." . PHP_EOL; 149 151 } 152 if ( $ms_files_message ) { 153 echo "Not running ms_files_rewriting tests... To execute these, use --group ms-files." . PHP_EOL; 154 } 150 155 } 151 156 } 152 157 new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] ); -
tests/phpunit/multisite.xml
23 23 <groups> 24 24 <exclude> 25 25 <group>ajax</group> 26 <group>ms-files</group> 26 27 </exclude> 27 28 </groups> 28 29 <php> -
tests/phpunit/tests/multisite/ms-files-rewriting.php
1 <?php 2 3 if ( is_multisite() ) : 4 5 /** 6 * Tests specific to the ms_files_rewriting option in multisite. 7 * 8 * The ms-files group tag must be used for these tests to run as the constants 9 * set in ms_upload_constants() conflict with a non ms-files configuration. 10 * 11 * @group ms-files 12 * @group multisite 13 */ 14 class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase { 15 protected $suppress = false; 16 17 function setUp() { 18 global $wpdb; 19 parent::setUp(); 20 $this->suppress = $wpdb->suppress_errors(); 21 22 $_SERVER[ 'REMOTE_ADDR' ] = ''; 23 24 update_site_option( 'ms_files_rewriting', 1 ); 25 ms_upload_constants(); 26 } 27 28 function tearDown() { 29 global $wpdb; 30 update_site_option( 'ms_files_rewriting', 0 ); 31 parent::tearDown(); 32 $wpdb->suppress_errors( $this->suppress ); 33 } 34 35 function test_switch_upload_dir() { 36 $this->assertTrue( is_main_site() ); 37 38 $site = get_current_site(); 39 40 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 41 $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) ); 42 $info = wp_upload_dir(); 43 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 44 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 45 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 46 $this->assertEquals( '', $info['error'] ); 47 48 switch_to_blog( $blog_id2 ); 49 $info2 = wp_upload_dir(); 50 $this->assertNotEquals( $info, $info2 ); 51 $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['url'] ); 52 $this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['path'] ); 53 $this->assertEquals( gmstrftime('/%Y/%m'), $info2['subdir'] ); 54 $this->assertEquals( '', $info2['error'] ); 55 restore_current_blog(); 56 } 57 } 58 59 endif; 60 No newline at end of file -
tests/phpunit/tests/multisite/site.php
949 949 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 950 950 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 951 951 $this->assertEquals( '', $info['error'] ); 952 953 update_site_option( 'ms_files_rewriting', 1 );954 ms_upload_constants();955 956 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );957 $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) );958 $info = wp_upload_dir();959 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );960 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] );961 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] );962 $this->assertEquals( '', $info['error'] );963 964 switch_to_blog( $blog_id2 );965 $info2 = wp_upload_dir();966 $this->assertNotEquals( $info, $info2 );967 $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['url'] );968 $this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime('%Y/%m'), $info2['path'] );969 $this->assertEquals( gmstrftime('/%Y/%m'), $info2['subdir'] );970 $this->assertEquals( '', $info2['error'] );971 restore_current_blog();972 update_site_option( 'ms_files_rewriting', 0 );973 952 } 974 953 975 954 /**