Ticket #24173: 24173.02.patch
File 24173.02.patch, 7.5 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( 'PATH_CURRENT_SITE' ) ) { 53 $_SERVER['REQUEST_URI'] = PATH_CURRENT_SITE; 54 } else { 55 define( 'PATH_CURRENT_SITE', '/' ); 56 } 57 52 58 define( 'SITE_ID_CURRENT_SITE', 1 ); 53 59 define( 'BLOG_ID_CURRENT_SITE', 1 ); 54 $GLOBALS['base'] = '/';60 $GLOBALS['base'] = PATH_CURRENT_SITE; 55 61 } else { 56 62 echo "Running as single site... To run multisite, use -c multisite.xml" . PHP_EOL; 57 63 } -
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( 'PATH_CURRENT_SITE' ) ) { 55 $path = PATH_CURRENT_SITE; 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 { 23 23 $details = get_blog_details( $blog_id, false ); 24 24 $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); 25 25 26 // support subdirectory installs 27 if ( defined( 'PATH_CURRENT_SITE' ) ) { 28 $slug = str_replace( PATH_CURRENT_SITE, '/', $details->path ); 29 } else { 30 $slug = $details->path; 31 } 32 $slug = trim( $slug, '/' ); 33 26 34 // 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' ) );35 $this->assertEquals( $blog_id, get_id_from_blogname( $slug ) ); 36 $this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . $slug, 'blog-details' ) ); 29 37 30 38 // get_blog_id_from_url() 31 39 $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); … … class Tests_MS extends WP_UnitTestCase { 352 360 $blog = get_blog_details( $blog_id ); 353 361 $this->assertEquals( $blog_id, $blog->blog_id ); 354 362 $this->assertEquals( $current_site->domain, $blog->domain ); 355 $this->assertEquals( '/', $blog->path );363 $this->assertEquals( PATH_CURRENT_SITE, $blog->path ); 356 364 357 365 // Test defaulting to current blog 358 366 $this->assertEquals( $blog, get_blog_details() ); 359 360 367 $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' ) ); 368 $blog_id = $this->factory->blog->create( array( 369 'user_id' => $user_id, 370 'path' => PATH_CURRENT_SITE . 'test_blogname', 371 'title' => 'Test Title' 372 ) ); 362 373 $this->assertInternalType( 'int', $blog_id ); 363 364 374 $this->assertEquals( 'http://' . DOMAIN_CURRENT_SITE . PATH_CURRENT_SITE . 'test_blogname/', get_blogaddress_by_name('test_blogname') ); 365 375 366 $this->assertEquals( $blog_id, get_id_from_blogname( 'test_blogname') );376 $this->assertEquals( $blog_id, get_id_from_blogname( 'test_blogname' ) ); 367 377 } 368 378 369 379 function _action_counter_cb( $blog_id ) { … … class Tests_MS extends WP_UnitTestCase { 525 535 526 536 /** 527 537 * Test fetching a blog that doesn't exist and again after it exists. 528 * 538 * 529 539 * @ticket 23405 530 540 */ 531 541 function test_get_blog_details_blog_does_not_exist() { … … class Tests_MS extends WP_UnitTestCase { 570 580 global $test_action_counter; 571 581 572 582 $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' ) );583 $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => PATH_CURRENT_SITE . 'test_blogpath', 'title' => 'Test Title' ) ); 574 584 $this->assertInternalType( 'int', $blog_id ); 575 585 576 586 $test_action_counter = 0; … … class Tests_MS extends WP_UnitTestCase { 939 949 $site = get_current_site(); 940 950 941 951 $info = wp_upload_dir(); 942 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );952 $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 943 953 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 944 954 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 945 955 $this->assertEquals( '', $info['error'] ); … … class Tests_MS extends WP_UnitTestCase { 949 959 950 960 switch_to_blog( $blog_id ); 951 961 $info = wp_upload_dir(); 952 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] );962 $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['url'] ); 953 963 $this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime('%Y/%m'), $info['path'] ); 954 964 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 955 965 $this->assertEquals( '', $info['error'] ); 956 966 restore_current_blog(); 957 967 958 968 $info = wp_upload_dir(); 959 $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'] ); 960 970 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 961 971 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 962 972 $this->assertEquals( '', $info['error'] ); … … class Tests_MS extends WP_UnitTestCase { 967 977 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 968 978 $blog_id2 = $this->factory->blog->create( array( 'user_id' => $user_id ) ); 969 979 $info = wp_upload_dir(); 970 $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] );980 $this->assertEquals( 'http://' . $site->domain . $site->path . 'wordpress/wp-content/uploads/' . gmstrftime('%Y/%m'), $info['url'] ); 971 981 $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime('%Y/%m'), $info['path'] ); 972 982 $this->assertEquals( gmstrftime('/%Y/%m'), $info['subdir'] ); 973 983 $this->assertEquals( '', $info['error'] ); … … class Tests_MS extends WP_UnitTestCase { 998 1008 'user_login' => $spam_username, 999 1009 ) ); 1000 1010 update_user_status( $spam_user_id, 'spam', '1' ); 1001 1011 1002 1012 $this->assertTrue( is_user_spammy( $spam_username ) ); 1003 1013 $this->assertFalse( is_user_spammy( 'testuser1' ) ); 1004 1014 }