Ticket #24173: 24173.01.patch
File 24173.01.patch, 7.8 KB (added by , 12 years ago) |
---|
-
includes/bootstrap.php
if ( $multisite ) { 48 48 define( 'MULTISITE', true ); 49 49 define( 'SUBDOMAIN_INSTALL', false ); 50 50 define( 'DOMAIN_CURRENT_SITE', WP_TESTS_DOMAIN ); 51 define( 'PATH_CURRENT_SITE', '/' ); 51 52 if ( defined( 'WP_TESTS_PATH' ) ) { 53 define( 'PATH_CURRENT_SITE', WP_TESTS_PATH ); 54 $_SERVER['REQUEST_URI'] = PATH_CURRENT_SITE; 55 } else { 56 define( 'PATH_CURRENT_SITE', '/' ); 57 } 58 52 59 define( 'SITE_ID_CURRENT_SITE', 1 ); 53 60 define( 'BLOG_ID_CURRENT_SITE', 1 ); 54 $GLOBALS['base'] = '/';61 $GLOBALS['base'] = PATH_CURRENT_SITE; 55 62 } else { 56 63 echo "Running as single site... To run multisite, use -c multisite.xml" . PHP_EOL; 57 64 } -
includes/install.php
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { 50 50 $wpdb->$table = $prefixed_table; 51 51 } 52 52 53 if ( $multisite ) { 54 if ( defined( 'WP_TESTS_PATH' ) ) { 55 $path = WP_TESTS_PATH; 56 } else { 57 $path = '/'; 58 } 59 60 // This will override wp_guess_url() when populating the install 61 // Note: we're suffixing with 'wordpress' since our WP install is in a subdirectory 62 define( 'WP_SITEURL', 'http://' . WP_TESTS_DOMAIN . $path . 'wordpress' ); 63 } 64 53 65 wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); 54 66 55 67 if ( $multisite ) { … … if ( $multisite ) { 61 73 $subdomain_install = false; 62 74 63 75 install_network(); 64 populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, '/', $subdomain_install );76 populate_network( 1, WP_TESTS_DOMAIN, WP_TESTS_EMAIL, $title, $path, $subdomain_install ); 65 77 } 66 78 67 79 file_put_contents( WP_TESTS_VERSION_FILE, $hash ); -
tests/ms.php
class Tests_MS extends WP_UnitTestCase { 24 24 $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); 25 25 26 26 // get_id_from_blogname(), see #20950 27 $this->assertEquals( $blog_id, get_id_from_blogname( $details->path ) ); 28 $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) ); 27 // support subdirectory installs 28 if ( defined( 'WP_TESTS_PATH' ) ) { 29 $slug = str_replace( '/', PATH_CURRENT_SITE, $details->path ); 30 } else { 31 $slug = trim( $details->path, '/' ); 32 } 33 $this->assertEquals( $blog_id, get_id_from_blogname( $slug ) ); 34 $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' ) ); 29 35 30 36 // get_blog_id_from_url() 31 37 $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); … … class Tests_MS extends WP_UnitTestCase { 352 358 $blog = get_blog_details( $blog_id ); 353 359 $this->assertEquals( $blog_id, $blog->blog_id ); 354 360 $this->assertEquals( $current_site->domain, $blog->domain ); 355 $this->assertEquals( '/', $blog->path );361 $this->assertEquals( PATH_CURRENT_SITE, $blog->path ); 356 362 357 363 // Test defaulting to current blog 358 364 $this->assertEquals( $blog, get_blog_details() ); 359 360 365 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 361 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogname', 'title' => 'Test Title' ) ); 366 $blog_id = $this->factory->blog->create( array( 367 'user_id' => $user_id, 368 'path' => PATH_CURRENT_SITE . 'test_blogname', 369 'title' => 'Test Title' 370 ) ); 362 371 $this->assertInternalType( 'int', $blog_id ); 363 364 372 $this->assertEquals( 'http://' . DOMAIN_CURRENT_SITE . PATH_CURRENT_SITE . 'test_blogname/', get_blogaddress_by_name('test_blogname') ); 365 373 366 $this->assertEquals( $blog_id, get_id_from_blogname( 'test_blogname') );374 $this->assertEquals( $blog_id, get_id_from_blogname( 'test_blogname' ) ); 367 375 } 368 376 369 377 function _action_counter_cb( $blog_id ) { … … class Tests_MS extends WP_UnitTestCase { 570 578 global $test_action_counter; 571 579 572 580 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 573 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) );581 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => PATH_CURRENT_SITE . 'test_blogpath', 'title' => 'Test Title' ) ); 574 582 $this->assertInternalType( 'int', $blog_id ); 575 583 576 584 $test_action_counter = 0; … … class Tests_MS extends WP_UnitTestCase { 930 938 $site = get_current_site(); 931 939 932 940 $info = wp_upload_dir(); 933 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );941 $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 934 942 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 935 943 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 936 944 $this->assertEquals( '', $info['error'] ); … … class Tests_MS extends WP_UnitTestCase { 940 948 941 949 switch_to_blog( $blog_id ); 942 950 $info = wp_upload_dir(); 943 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] );951 $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] ); 944 952 $this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['path'] ); 945 953 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 946 954 $this->assertEquals( '', $info['error'] ); 947 955 restore_current_blog(); 948 956 949 957 $info = wp_upload_dir(); 950 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );958 $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 951 959 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 952 960 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 953 961 $this->assertEquals( '', $info['error'] ); … … class Tests_MS extends WP_UnitTestCase { 958 966 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 959 967 $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) ); 960 968 $info = wp_upload_dir(); 961 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );969 $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 962 970 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 963 971 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 964 972 $this->assertEquals( '', $info['error'] ); … … class Tests_MS extends WP_UnitTestCase { 990 998 ) ); 991 999 update_user_status( $spam_user_id, 'spam', '1' ); 992 1000 993 $this->assertTrue( is_user_spammy( $spam_user name) );1001 $this->assertTrue( is_user_spammy( $spam_user_id ) ); 994 1002 $this->assertFalse( is_user_spammy( 'testuser1' ) ); 995 1003 } 996 1004 -
wp-tests-config-sample.php
define( 'DB_COLLATE', '' ); 31 31 $table_prefix = 'wptests_'; // Only numbers, letters, and underscores please! 32 32 33 33 define( 'WP_TESTS_DOMAIN', 'example.org' ); 34 define( 'WP_TESTS_EMAIL', 'admin@example.org' ); 35 define( 'WP_TESTS_TITLE', 'Test Blog' ); 34 define( 'WP_TESTS_PATH', '/' ); 35 define( 'WP_TESTS_EMAIL', 'admin@example.org' ); 36 define( 'WP_TESTS_TITLE', 'Test Blog' ); 36 37 37 38 define( 'WP_PHP_BINARY', 'php' ); 38 39